//元方法名称
const objFun = "objectHide";
//屏幕加载
const scrLoad = "create";
//屏幕销毁
const scrFree = "free";
//表示控件本身对象的 key 值
const objectSelf = "self";
//控件属性设置的对象名称
//具体为：控件名称 + .self
const widObjName = '.' + objectSelf;
//默认父级屏幕样式名称
const defContStyleName = "lvgl_UiDesigner_DefaultContStyle";

//回调函数文件中的原始函数信息
let originalHandleTable;
//回调函数文件中的原始数据
let originalHandleData = "";
//记录去重的函数名称
let repeatHandle;
//提示版本是否是 SOC
let isSoc = false;
//资源对象
let resource;


/*
获取图片的原始与当前大小的比例
@imageDir:          图片地址
@curImgSize:        当前图片大小(长宽)

@return:            返回比例的整数值
*/
function lvglGetImageZoomScale(imageDir, curImgSize) {
    let zoomScale = 0;
    // 激活过程的根地址路径
    let actProRootDir = path.join(path.dirname(gDesigFilePath), "..");
    if (actProRootDir) {
        //图片原始大小(长宽)
        let imgAbsSize = imageSize(actProRootDir + "\\" + imageDir);
        let scale = (curImgSize.width / imgAbsSize.width) * 256;
        zoomScale = parseInt(scale);
        return zoomScale;
    }
}

/*
获取图片的原始与当前大小的比例
@imageDir:          图片地址
@curImgSize:        当前图片大小(长宽)

@return:            返回比例的整数值
*/
function lvglGetImageResScale(imageDir, curImgSize){
    let imgDir = imageDir.replace("/", "\\");
    if (resource.resources[imgDir]){
        let zoomScale = (curImgSize.width / resource.resources[imgDir].width) * 256;
        return parseInt(zoomScale);
    }
    return undefined;
}

/*
自动的生成样式名称
格式：              控件名称 + Style + 数字
@tar                控件名称
@cur                当前的序号数
@return             样式名称
*/
function autoBuildStyleName(tar, cur) {
    let styleName = "Style_" + tar;
    styleName += "_" + cur;
    return styleName;
}

/*
自动的生成控件部位
@tar                控件的类型缩写
@part               控件的部位
@return             控件的部位宏
*/
function autoBuildPartOfWid(tar, part) {
    let type = tar.slice(tar, 4);
    type = tar.toUpperCase();
    type = "lvgl.".concat(type);
    type = type.concat("_PART_");
    type = type.concat(part);
    return type;
}

/*
判断lvgl控件的类型
@widgets:           输入控件的类型
@return:            输出相应的类型ID
*/
function lvglTypeChoose(widgets) {
    let type = "";
    switch (widgets) {
        case "LvglObj":
            type = "obj";
            break;
        case "LvglArc":
            type = "arc";
            break;
        case "LvglBar":
            type = "bar";
            break;
        case "LvglButton":
            type = "btn";
            break;
        case "LvglBtnMatrix":
            type = "btnmatrix";
            break;
        case "LvglCalendar":
            type = "calendar";
            break;
        case "LvglCheckbox":
            type = "checkbox";
            break;
        case "LvglChart":
            type = "chart";
            break;
        case "LvglCont":
            type = "cont";
            break;
        case "LvglCPicker":
            type = "cpicker";
            break;
        case "LvglDropdown":
            type = "dropdown";
            break;
        case "LvglGauge":
            type = "gauge";
            break;
        case "LvglImg":
            type = "img";
            break;
        case "LvglImgBtn":
            type = "imgbtn";
            break;
        case "LvglTextarea":
            type = "textarea";
            break;
        case "LvglKeyboard":
            type = "keyboard";
            break;
        case "LvglLabel":
            type = "label";
            break;
        case "LvglLed":
            type = "led";
            break;
        case "LvglLine":
            type = "line";
            break;
        case "LvglList":
            type = "list";
            break;
        case "LvglLineMeter":
            type = "linemeter";
            break;
        case "LvglMessageBox":
            type = "msgbox";
            break;
        case "LvglPage":
            type = "page";
            break;
        case "LvglRoller":
            type = "roller";
            break;
        case "LvglSlider":
            type = "slider";
            break;
        case "LvglSpinbox":
            type = "spinbox";
            break;
        case "LvglSpinner":
            type = "spinner";
            break;
        case "LvglSwitch":
            type = "switch";
            break;
        case "LvglTable":
            type = "table";
            break;
        case "LvglTabView":
            type = "tabview";
            break;
        case "LvglTileView":
            type = "tileview";
            break;
        case "LvglWindow":
            type = "win";
            break;
        case "LvglQrcode":
            type = "qrcode";
            break;
        default:
            console.log("The widgets that you inputs is error")
            break;
    }
    return type;
}

/*
获取样式中的相应的部位，并把它转换为大写
*/
function lvglGetPart(part) {
    if (part.search(/Part/) > 0) {
        let temPart = part.replace(/Part/, "");
        temPart = temPart.replace(/([A-Z])+/g, "_$1").toUpperCase();
        return temPart;
    }
}

/*
获取样式中的相应的状态，并把它转换为大写
*/
function lvglGetStatus(status, type) {
    if (status.search(/Status/) > 0) {
        let temStatus = status.replace(/Status/, "");
        temStatus = temStatus.toUpperCase();
        //对按钮的特殊状态进行适配
        if (type === "btn" || type === "imgbtn") {
            if (temStatus.includes("CHECKED")) {

            } else {
                if (temStatus.includes("RELEASED") || temStatus.includes("PRESSED") || temStatus.includes("DISABLED")) {
                    temStatus = "lvgl.STATE_".concat(temStatus);
                } else {
                    temStatus = "lvgl.STATE_".concat(temStatus);
                }
            }
        } else {
            temStatus = "lvgl.STATE_".concat(temStatus);
        }
        return temStatus;
    }
}

/*
把格式为 abcDefHi 字符串修改为 abc_def_hi 格式  
*/
function transStrForamt(tar) {
    let i = tar.search(/[A-Z]/);
    if (i > 0) {
        let head = tar.slice(tar, i);
        if (i + 1 === tar.length) {
            let body = tar.slice(i);
            body = "_".concat(body.toLowerCase());
            head = head.concat(body);
        } else {
            let body = tar.match(/[A-Z][a-z]+/g);
            for (let j = 0; j < body.length; j++) {
                head = head.concat("_");
                head = head.concat(body[j].toLowerCase());
            }
        }
        return head;
    } else {
        return tar;
    }
}

/*
格式为：    lvgl.style_set_ + 通用属性字符串 + _ 通用属性字符串 : 具体的属性值
*/
function lvglSpliceStyle(val) {
    let temVal = {};
    let str = "lvgl.style_set_";
    for (let obj in val) {
        str = str.concat(obj);
        if (typeof (val[obj]) === "object") {
            let temStr = str;
            for (let key in val[obj]) {
                temStr = temStr.concat("_");
                let tkey = transStrForamt(key);
                temStr = temStr.concat(tkey);
                temVal[temStr] = val[obj][key];
                temStr = str;
            }
        } else {
            temVal[str] = val[obj];
        }
        str = "lvgl.style_set_";
    }
    return temVal;
}

/*
判断值不是空值，即不为 null
@tar:           值
@return:        值为null,   返回 false
                值不为null, 返回 true
*/
function isValueNotNull(tar) {
    if (tar) {
        return true;
    }
    return false;
}

/*
判断是否去把key值插入到obj中
逻辑：  
        存在：                  不插入
        不存在：                插入
@tar:                   Key
@obj:                   Object
@return:                true/false
*/
function canInsertKeyToObj(tar, obj) {
    return (obj.hasOwnProperty(tar) ? false : true);
}

/*
处理字符串获取最后一个 / 后面的字符串
*/
function getStringLastEcString(str){
    let temStr = str.match(/\w+\.\w+$/);
    if (temStr){
        return temStr[0];
    }
    return undefined;
}

/*
转换Json格式为lvgl代码生成的相应包含关系
@obj                    控件的样式对象
@type                   控件的类型
{
MAIN: {
    'lvgl.DEFAULT': {
        'lvgl.style_set_radius': 20,
        'lvgl.style_set_bg_color': '0xFFFFFF',
        'lvgl.style_set_bg_opa': 0.8,
        'lvgl.style_set_bg_grad_color': '0xFFFFFF',
        },
    }
}
*/
function transJsonFormat(obj, type) {
    let schema = {};
    let ikey;
    for (let key in obj) {
        if (typeof (obj[key]) === "object" && key != "event" && key != "anim" && key.includes("Status")) {
            for (let tkey in obj[key]) {
                if (typeof(obj[key][tkey]) === "object"){
                    ikey = lvglGetPart(tkey);
                    if (canInsertKeyToObj(ikey, schema)) {
                        schema[ikey] = {};
                    }
                    let val = (ikey.toLowerCase()).concat("Part");
                    let status = lvglGetStatus(key, type);
                    schema[ikey][status] = obj[key][val];
                }
            }
        }
    }
    let temSchema = {};
    for (let a in schema) {
        temSchema[a] = {};
        for (let b in schema[a]) {
            temSchema[a][b] = {};
            temSchema[a][b] = lvglSpliceStyle(schema[a][b]);
        }
    }
    return temSchema;
}

/* 忽略字符串的转义 */
function disStringEscape(tar){
    return tar.replace(/\\/g, '\\\\').replace(/\n/g, '\\n');
}

/*
获取屏幕中控件的基础的属性: 大小，位置，对其方式
*/
function lvglGetWidBaseValue(tar) {
    let base = {};
    for (let key in tar) {
        if (key === "width" || key === "height" || key === "x" || key === "y" || key === "align" || key === "name" || key === "body") {
            base[key] = tar[key];
        }
    }
    return base;
}

/*
获取控件中的非样式属性
@tar                    原始 json 数据中的 schema 对象
@return                 处于 schema 对象中的非样式属性
*/
function lvglGetWidNonStyleValue(tar) {
    let nonStyleObj = {};
    for (let key in tar) {
        nonStyleObj[key] = {};
        let valObj = tar[key]["comConf"];
        for (let val in valObj) {
            let isTar = val.includes("Status")
            if (val != "events" && val != "anim" && !isTar) {
                nonStyleObj[key][val] = valObj[val];
            }
        }
    }
    return nonStyleObj;
}

/*
获取控件的事件属性
@tar                    原始 json 数据中的 schema 对象
@return                 处于 schema 对象中的事件属性
*/
function lvglGetWidEventValue(tar) {
    let eventObj = {};
    for (let key in tar) {
        eventObj[key] = {};
        for (let val in tar[key]) {
            if (val.includes("event")) {
                eventObj[key]["event"] = tar[key]["event"];
            }
        }
    }
    return eventObj;
}

/*
通过子级名称获取[子级相对父级]的相对名称对象
@tar                blocks对象
@par                当前父级名称
@name               要寻找父级屏幕的子级名称
"blocks": 
[
    {
        "width": 400,
        "height": 50,
        "name": "LvglBar",
        "body": "LvglBar1",
        "x": 10,
        "y": 10,
        "blocks"[...]
    },
]
*/
function lvglSplicWidAndParentScreen(tar, par, name) {
    let retName = par;
    //遍历控件对象
    for (let j = 0; j < tar.length; j++) {
        if (name === tar[j].name) {
            // console.log("--子级--", name);
            retName += "." + name;
            break;
        }
    }
    return retName;
}

/*
获取控件的父级元素名称(父级元素名称相对于所在屏幕)
@tar                控件所在的屏幕对象
@par                控件当前的父级
@childName          所要寻找的控件名称
@return             返回父级元素名称
tar的格式为：
"screens": [
    {
        "name": "scr1",
        "layout": {
            "type": "free",
            "blocks": [
                {
                    "name": "aa1",
                    "body": "aa1",
                    "blocks": [
                        {
                            "name": "aa1_1",
                            "body": "aa1_1",
                        }
                    ]
                },
                ...
            ]
        }
    },
    {
        "name": "sc2",
        "layout": {
            "type": "free",
            "blocks": [
                {
                    "name": "bb1",
                    "body": "bb1",
                }
            ]
        }
    }
],
*/
let lvglRecursGetWidParentReferToScreen = function (tar, par, childName) {
    for (let i = 0; i < tar.length; i++)
    {
        if (tar[i].name == childName)
        {
            return par;
        }
        else
        {
            if (tar[i].hasOwnProperty("blocks"))
            {
                let ret = lvglRecursGetWidParentReferToScreen(tar[i]["blocks"], tar[i].name, childName);
                if (ret){
                    return ret;
                }
            }
        }
    }
    return null;
}

/*
获取控件的父级
@tar                屏幕总对象
@name               要寻找父级的对象
@return             父级对象名称
"screens": 
[
    {
        "name": "init",
        "layout": {
            "type": "free",
            "blocks": 
            [
                {
                    "width": 160,
                    "height": 160,
                    "name": "LvglArc1",
                    "body": "LvglArc1",
                    "x": 37,
                    "y": 25,
                    blocks: [
                        ...
                    ]
                }
            ]
        }
    },
    ...
],
*/
function lvglGetWidNameReferToScreen(tar, name) {
    for (let key in tar)
    {
        if (key == "layout")
        {
            for (let key2 in tar[key])
            {
                if (key2 == "blocks")
                {
                    let ret = lvglRecursGetWidParentReferToScreen(tar[key][key2], tar.name, name);
                    if (ret){
                        return ret;
                    }
                }
            }
        }
    }
}

/*
获取事件对象中的事件类型为invoke的事件的名称
@tar            事件对象
@return         返回事件名称组成的表
*/
function lvglGetEventNameByEventObj(tar, curEventTable) {
    for (let key in tar) {
        if (tar[key]["type"] === "invoke") {
            let len = curEventTable.length;
            if (tar[key]["name"]) {
                curEventTable[len] = tar[key]["name"];
            }
        }
    }
    return curEventTable;
}

/*
获取控件所在最外层父屏幕及控件的基本属性
@singleScr          单个屏幕的 blocks 对象
@widName            待寻找的控件名称
@grandParScr        控件当前的最外层父屏幕
@return             
    widBaseVal      控件的基本属性
    grandParScr     返回控件所在最外层父屏幕
*/
let lvglRecursGetWidParentScreen = function (singleScr, widName, grandParScr) {
    for (let j = 0; j < singleScr.length; j++) {
        //判断是否是寻找的控价
        if (singleScr[j].body == widName) {
            let widBaseVal = lvglGetWidBaseValue(singleScr[j]);
            // console.log('[LOG - widBaseVal]: ', widBaseVal);
            return [widBaseVal, grandParScr];
        } else {
            if (singleScr[j].hasOwnProperty("blocks")) {
                let ret = lvglRecursGetWidParentScreen(singleScr[j]["blocks"], widName, grandParScr);
                if (ret) {
                    return ret;
                }
            }
        }
    }
    return undefined;
}

/*
获取控件的所在屏幕的回调函数
@scrs               屏幕总对象
@widName            待寻找的控件名称
@return             
    ret[0]      控件的基本属性
    ret[1]     返回控件所在最外层父屏幕
*/
function lvglGetWidParentScreenInit(scrs, widName) {
    let ret = undefined;
    for (let i = 0; i < scrs.length; i++) {
        let grandParScr = scrs[i];
        let singleScr = scrs[i]["layout"]["blocks"];
        ret = lvglRecursGetWidParentScreen(singleScr, widName, grandParScr);
        if (ret) break;
    }
    return ret;
}

/*
整理 JSON 文件中的控价的属性
@allBaseObj         基本配置对象
@widValObj          JSON 文件中的 schema 对象
@speObj             控件独有的属性
@curHandleTable     当前 JSON 文件中的事件表
@temScrs            所有的屏幕对象
*/
function lvglGetWidValueFromSchema(allBaseObj, widValObj, speObj, curHandleTable, temScrs){
    //遍历 schema 控件属性对象
    for (let widName in widValObj) {
        // 获取控件所在的屏幕及控件的基本属性数组
        let temWidParObj = lvglGetWidParentScreenInit(temScrs, widName);
        //防止此控件不在当前屏幕中
        if (temWidParObj) {
            // 控件所在的最外层父级屏幕
            let parScr = temWidParObj[1];
            // 控件的基础属性对象
            let widBaseValObj = temWidParObj[0];
            //定位属性对象
            for (let val in widValObj[widName]) {
                if (val === "comConf") {
                    let temObj = {};
                    let len = allBaseObj.length;
                    //添加控件的样式以及基础的位置/大小/对齐属性
                    allBaseObj[len] = {};
                    allBaseObj[len][widName] = {};
                    //控件的基础属性
                    allBaseObj[len][widName]["base"] = widBaseValObj;
                    //控件的类型
                    allBaseObj[len][widName]["type"] = lvglTypeChoose(widValObj[widName].comType);
                    //获取控件所在的父级屏幕名称
                    allBaseObj[len][widName]["screen"] = parScr.name;
                    let styleNameIndex = 1;
                    let temType = lvglTypeChoose(widValObj[widName].comType);
                    let temStyleObj = transJsonFormat(widValObj[widName][val], temType);
                    //获取控件相对所在屏幕的对象名称
                    let widObjectName = parScr.name + "." + widBaseValObj.name;
                    //获取控件的父级对象(父级名称相对于所在屏幕)
                    let widObjectPar = lvglGetWidNameReferToScreen(parScr, widBaseValObj.name);
                    //对控件的父级对象进行相应的处理
                    widObjectPar = (widObjectPar === parScr.name ? widObjectPar + ".contFather_" + widObjectPar : parScr.name + "." + widObjectPar + widObjName);
                    for (let part in temStyleObj) {
                        //格式化控件的状态
                        let styleName = autoBuildStyleName(widName, styleNameIndex);
                        styleNameIndex = styleNameIndex + 1;
                        temStyleObj[part]["styName"] = styleName;
                        temStyleObj[part]["objName"] = widObjectName;
                        //格式化控件的部位
                        let type = lvglTypeChoose(widValObj[widName].comType);
                        type = autoBuildPartOfWid(type, part);
                        temObj[type] = temStyleObj[part];
                    }
                    //通过父级获取子级对象名称
                    allBaseObj[len][widName]["name"] = widObjectName;
                    allBaseObj[len][widName]["parent"] = widObjectPar;
                    allBaseObj[len][widName]["style"] = temObj;
                    allBaseObj[len][widName]["special"] = speObj[widName];
                    if (widValObj[widName][val].hasOwnProperty("events")) {
                        allBaseObj[len][widName]["event"] = widValObj[widName][val]["events"];
                        curHandleTable = lvglGetEventNameByEventObj(widValObj[widName][val]["events"], curHandleTable);
                    }
                    //当已匹配上所需要的控件则跳出循环
                    break;
                }
            }
        }
    }
    return [allBaseObj, curHandleTable];
}

/*
递归循环对控件进行排序
@curScrTable            当前控件的属性对象
@sortArr                当前已排序的控件数组
@unSortArr              未排序的控件数组
*/
let lvglRecursSortWid = function (curScrTable, sortArr, unSortArr) {
    //获取当前屏幕的顺序控件
    for (let j = 0; j < curScrTable.length; j++) {
        //获取寻找的控价属性对象名称
        let curWigBody = curScrTable[j].body;
        for (let l = 0; l < unSortArr.length; l++) {
            if (unSortArr[l][curWigBody]){
                sortArr[sortArr.length] = unSortArr[l];
            }
        }
        if (curScrTable[j].blocks) {
            if (curScrTable[j].blocks.length > 0) {
                sortArr = lvglRecursSortWid(curScrTable[j].blocks, sortArr, unSortArr);
            }
        }
    }
    return sortArr;
}

/*
对控件对象表进行顺序排列
@allWidObj          处理后的所有控件对象
@scrRelation        控件的关系表
*/
function lvglSortWidObj(allWidObj, scrRelation) {
    let sortArr = [];
    let unSortArr = allWidObj;

    for (let i = 0; i < scrRelation.length; i++) {
        let curScrTable = scrRelation[i].layout.blocks;
        let ret = lvglRecursSortWid(curScrTable, sortArr, unSortArr);
        ret = sortArr;
    }

    return sortArr;
}

/*
获取控件的样式对象
@tar                json格式的数据
@allWidObj          格式化后的json数据
格式：
[
    {
        schema3: {
            "base": { width: 100, height: 100, x: 79, y: 100, align: 'OUT_BOTTOM_MID' },
            "type": 'arc',
            "screen": 'sceneA',
            "name": 'sceneA.blockA9',
            "parent": 'sceneA.contFather_sceneA',
            "style": {
                'lvgl.ARC_PART_MAIN': {
                    'lvgl.STATE_DEFAULT': {
                        'lvgl.style_set_radius': 20,
                        'lvgl.style_set_bg_color': '0xFFFFFF',
                        'lvgl.style_set_bg_opa': 0.8,
                        'lvgl.style_set_bg_grad_color': '0xFFFFFF',
                        'lvgl.style_set_bg_main_stop': 20,
                        'lvgl.style_set_bg_grad_stop': 250,
                        'lvgl.style_set_bg_grad_dir': 'HOR',
                        'lvgl.style_set_bg_blend_mode': 'NORMAL',
                        'lvgl.style_set_bg_op_y': 30
                    },
                    styName: 'Style_schema3_1',
                    objName: 'sceneA.blockA9'
                },
                ...
            },
            "special": [Object]
            "event": {
                "CLICKED": {
                    "type": 'invoke',
                    "name": 'clickedHandle'
                },
                "PRESSED": {
                    "type": 'window',
                    "name": 'pressedHandle'
                },
            }
        }
    },
    ...
]
*/
function styleManage(json) {
    //当前的json文件中的回调函数表
    let curHandleTable = [];
    //基础配置信息表
    let allBaseCfg = {};
    //基础控件属性表
    let allBaseObj = [];
    //控件的属性对象
    let widValObj = json.schema;
    //屏幕数组
    let temScrs = json.screens;
    //保存基础配置信息
    for (let cfg in json) {
        if (cfg != "screens" && cfg != "schema") {
            allBaseCfg[cfg] = json[cfg];
        }
    }
    //在基础配置中添加屏幕数组
    allBaseCfg["screens"] = temScrs;
    //获取控件非样式属性
    let allWidSpeObj = lvglGetWidNonStyleValue(widValObj);
    //遍历 schema 控件属性对象
    let widRet = lvglGetWidValueFromSchema(allBaseObj, widValObj, allWidSpeObj, curHandleTable, temScrs);
    allBaseObj = widRet[0];
    curHandleTable = widRet[1];
    //对生成的控件对象表进行顺序排列
    allBaseObj = lvglSortWidObj(allBaseObj, temScrs);
    //console.log('[LOG - allObj]: ', allBaseObj, allBaseObj.length);
    // console.log("回调函数文件中的数据: \n", curHandleTable);
    return [allBaseObj, allBaseCfg, curHandleTable];
}

/*
 ******************************************************************************************************************************
 *************************************************以下的是关于控件的特有属性的判断************************************************
 ******************************************************************************************************************************
 */

/*
特有属性格式
"comConf": {
    "type": "NORMAL/REVERSE/SYMMETRIC",             //格式为：lvgl.ARC_TYPE_NORMAL
    "bg_start_angle": 0,                            //0-360
    "bg_end_angle": 360,                            //0-360
    "start_angle": 0,                               //0-360
    "end_angle": 360,                               //0-360
    "rotation": 0,                                  //0-360
    "drag": true,
    "value": 120,                                   //0-360
//部位：    lvgl.ARC_PART_BG/INDIC/KNOB
    ...
},
*/
function lvglArcSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "drag" && tar[val]) {
                strCode += "\x09lvgl.arc_is_dragged(" + name + ")\n";
            } else if (temVal === "type") {
                strCode += "\x09lvgl.arc_set_" + temVal + "(" + name + ", " + "lvgl." + tar[val] + ")\n";
            } else if (temVal === "adjustable") {
                strCode += "\x09lvgl.arc_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "bg_end_angle" || temVal === "bg_start_angle" || temVal === "start_angle" || temVal === "end_angle") {
                strCode += "\x09lvgl.arc_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            } else if (temVal === "range"){
                strCode += "\x09lvgl.arc_set_" + temVal + "(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "value" || temVal === "rotation") {
                strCode += "\x09lvgl.arc_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "type": "SYMMETRICAL/NORMAL/CUSTOM",    //格式为：lvgl.BAR_TYPE_NORMAL
    "range": [0, 100],
    "start_value": [20, "ON"],
    "anim_time": 5000,
    "value": [80, "ON"],
//部位：    lvgl.BAR_PART_BG/INDIC
    ...
},
*/
function lvglBarSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "type") {
                strCode += "\x09lvgl.bar_set_" + temVal + "(" + name + ", " + "lvgl." + tar[val] + ")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "range") {
                strCode += "\x09lvgl.bar_set_" + temVal + "(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
            } else if (temVal === "anim_time") {
                strCode += "\x09lvgl.bar_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "value") {
                strCode += "\x09lvgl.bar_set_" + temVal + "(" + name + ", " + tar[val][0] + ", lvgl." + tar[val][1] + ")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "start_value") {
                strCode += "\x09lvgl.bar_set_" + temVal + "(" + name + ", " + tar[val][0] + ", lvgl." + tar[val][1] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "bright": 200,                                  //(0-255)
    "status": "ON/OFF",
    "toggle": true/false,     
//部位：   lvgl.LED_PART_MAIN
    ...
},
*/
function lvglLedSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            if (val === "toggle" && tar[val]) {
                strCode += "\x09lvgl.led_toggle(" + name + ")\n";
                strCode += "\x09lvgl.led_set_bright(" + name + ", " + tar["bright"] + ")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            if (val === "state") {
                if (tar[val] === "ON") {
                    strCode += "\x09lvgl.led_on(" + name + ")\n";
                } else {
                    strCode += "\x09lvgl.led_off(" + name + ")\n";
                }
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "txt": "http://www.baidu.com"
//部位：   lvgl.QRCODE_PART_MAIN
    ...
},
*/
function lvglQrcodeSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            if (val === "txt") {
                let newVal = disStringEscape(tar[val]);
                strCode += "\x09lvgl.qrcode_set_txt(" + name + ", \"" + newVal + "\")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "long_mode": "EXPAND/BREAK/DOT/SROLL/SROLL_CIRC/CROP",  //格式为：lvgl.LABEL_LONG_EXPAND
    "align": "LEFT/CENTER/RIGHT/AUTO",      //格式为：lvgl.LABEL_ALIGN_LEFT
    "anim_speed": 5000,
    "recolor": true/false,
    "text": "哈哈哈",
//部位：    lvgl.LABEL_PART_MAIN
    ...
},
*/
function lvglLabelSpe(name, tar, labelBase) {
    let strCode = "";
    let isLongMode = true;
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "align") {
                strCode += "\x09lvgl.label_set_" + temVal + "(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "long_mode") {
                if (tar[val] === "LABEL_LONG_EXPAND"){
                    isLongMode = false;
                }
                strCode += "\x09lvgl.label_set_" + temVal + "(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "recolor" || temVal === "anim_speed") {
                strCode += "\x09lvgl.label_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    if (isLongMode){
        strCode += "\x09lvgl.obj_set_width(" + name + ", " + labelBase.width + ")\n";
        strCode += "\x09lvgl.obj_set_height(" + name + ", " + labelBase.height + ")\n";
    }
    for (let val2 in tar) {
        if (isValueNotNull(tar[val2]) || tar[val2] === "") {
            if (val2 === "text") {
                let newVal = disStringEscape(tar[val2]);
                strCode += "\x09lvgl.label_set_" + val2 + "(" + name + ", \"" + newVal + "\")\n";
            }
        }
    }
    return strCode;
}

/*
为按钮添加子级Label (弃用)
@faName:        按钮的名称
@tar:           虚拟 label 的属性
@faStyleName:   按钮的样式名称
*/
function lvglVirtualLabelInBtn2(faName, tar, faStyleName){
    let laName = faName.match(/(?<=\.)\w+(?=\.)/);
    //虚拟label名称
    let name = "vLabel_" + laName;
    //添加属性
    let code = "\x09--This is the virtual Label of " + laName + "\n";
    code += "\x09" + name + " = lvgl.label_create(" + faName + ", nil)\n";
    for (let val in tar.comConf){
        if (isValueNotNull(tar.comConf[val]) || tar.comConf[val] === "") {
            if (val === "text") {
                let newVal = disStringEscape(tar.comConf[val]);
                code += "\x09lvgl.label_set_" + val + "(" + name + ", \"" + newVal + "\")\n";
            }
        }
    }
    //添加样式
    code += "\x09lvgl.obj_add_style(" + name + ", lvgl.LABEL_PART_MAIN, " + faStyleName + ")\n"

    return code;
}

/*
为按钮添加子级Label
@faName:        按钮的名称
@tar:           虚拟 label 的属性
@faStyleName:   按钮的样式名称
*/
function lvglVirtualLabelInBtn(faName, tar, faStyleName){
    let laName = faName.match(/(?<=\.)\w+(?=\.)/);
    //虚拟label名称
    let name = "vLabel_" + laName;
    let code = "\x09--This is the virtual Label of " + laName + "\n";
    //创建样式
    let styleName = "Style_" + laName + "_vLabel";
    code += "\x09" + styleName + " = lvgl.style_t()\n";
    code += "\x09lvgl.style_init(" + styleName + ")\n";
    for (let val in faStyleName){
        if (val.includes("text_color")){
            let curColor = faStyleName[val].replace("#", "0x");
            code += "\x09lvgl.style_set_text_color(" + styleName + ", lvgl.STATE_DEFAULT, lvgl.color_hex(" + curColor + "))\n";
        } else if (val.includes("text_font")){
            let cSt = faStyleName[val];
            if (isValueNotNull(cSt["weight"]) && isValueNotNull(cSt["size"]) && (cSt["name"] != "SimSun")){
                let font = "lvgl.font_load(\"" + (cSt["weight"]).toLowerCase() + "\", " + cSt["size"] + ")";
                code += "\x09lvgl.style_set_text_font(" + styleName + ", lvgl.STATE_DEFAULT, " + font + ")\n";
            }
        }
    }

    //添加属性
    code += "\x09" + name + " = lvgl.label_create(" + faName + ", nil)\n";
    for (let val in tar.comConf){
        if (isValueNotNull(tar.comConf[val]) || tar.comConf[val] === "") {
            if (val === "text") {
                let newVal = disStringEscape(tar.comConf[val]);
                code += "\x09lvgl.label_set_" + val + "(" + name + ", \"" + newVal + "\")\n";
            }
        }
    }
    //添加样式
    code += "\x09lvgl.obj_add_style(" + name + ", lvgl.LABEL_PART_MAIN, " + styleName + ")\n"

    return code;
}

/*
特有属性格式
"comConf": {
    "checkable": true/false,
    "state": lvgl.BTN_STATE_RELEASED/PRESSED/CHECKED_RELEASED/CHECKED_PRESSED/DISABLED/CHECKED_DISABLED,
    "virtualLabel": 虚拟文字
//部位：    lvgl.BTN_PART_MAIN
    ...
},
*/
function lvglBtnSpe(name, tar, style) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            if (val === "checkable" && !tar[val]) {
                strCode += "\x09lvgl.btn_set_checkable(" + name + ", false)\n";
            } else if (val === "virtualLabel"){
                strCode += lvglVirtualLabelInBtn(name, tar[val], style["lvgl.BTN_PART_MAIN"]["lvgl.STATE_DEFAULT"]);
            } else if (val === "state") {
                strCode += "\x09lvgl.btn_set_state(" + name + ", lvgl." + tar[val] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "text": "是否点击",
    "checked": true/false,        //是否被勾选中
    "disabled": true/false,       //是否被禁止选中
//部位：    lvgl.CHECKBOX_PART_BG/BULLET
    ...
},
*/
function lvglCheckBoxSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            if (val === "text") {
                strCode += "\x09lvgl.checkbox_set_" + val + "(" + name + ", \"" + tar[val] + "\")\n";
            }
            else if (val === "checked" || val === "disabled") {
                strCode += "\x09lvgl.checkbox_set_" + val + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "today_date": [2021, 11, 1],
    "showed_date": [2021, 10, 6],
    "highlighted_dates": [[2021, 11, 11], [2021, 11, 15]],          //元素依次为：年月日, 上述同理
                                                                    //暂时不支持多个高亮，仅支持高亮1个
    "day_names": ["星期一", "星期二", ...],                          //设置一周的天数名称
    "month_names": ["一月", "二月", ...],                       //设置月份的名称
//部位：    lvgl.CALENDAR_PART_BG/HEADER/DAY_NAMES/DATE
    ...
},
*/
function lvglCalendarSpe(name, tar) {
    let strCode = "";
    let temVar = name.slice(name.indexOf(".") + 1)
    temVar = temVar.replace("." + objectSelf, "");
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "today_date" || temVal === "showed_date") {
                strCode += "\x09" + val + temVar + " = lvgl.calendar_date_t()\n";
                strCode += "\x09" + val + temVar + ".year = " + tar[val][0] + "\n\x09" + val + temVar + ".month = " + tar[val][1] + "\n\x09" + val + temVar + ".day = " + tar[val][2] + "\n";
                strCode += "\x09lvgl.calendar_set_" + temVal + "(" + name + ", " + val + temVar + ")\n";
            } else if (temVal === "highlighted_dates") {
                strCode += "\x09" + val + temVar + " = lvgl.calendar_date_t()\n";
                for (let j = 0; j < tar[val].length; j++) {
                    if (tar[val].length === 1) {
                        strCode += "\x09" + val + temVar + ".year = " + tar[val][j][0] + "\n\x09" + val + temVar + ".month = " + tar[val][j][1] + "\n\x09" + val + temVar + ".day = " + tar[val][j][2] + "\n";
                    } else {
                        strCode += "\x09" + val + temVar + "[" + (j + 1) + "].year = " + tar[val][j][0] + "\n\x09" +
                            val + temVar + "[" + (j + 1) + "].month = " + tar[val][j][1] + "\n\x09" +
                            val + temVar + "[" + (j + 1) + "].day = " + tar[val][j][2] + "\n\x09";
                    }
                }
                strCode += "\x09lvgl.calendar_set_" + temVal + "(" + name + ", " + val + temVar + ", " + tar[val].length + ")\n";
            } else {
                strCode += "\x09" + val + temVar + " = {";
                for (let i = 0; i < tar[val].length; i++) {
                    if (i + 1 === tar[val].length) {
                        strCode += "\"" + tar[val][i] + "\"" + "}\n";
                    } else {
                        strCode += "\"" + tar[val][i] + "\"" + ", ";
                    }
                }
                strCode += "\x09lvgl.calendar_set_" + temVal + "(" + name + ", " + val + temVar + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "anim_time": 5000,
    "auto_fit": true/false,
    "options": ["星期一\\n星期二\\n星期三\\n星期四\\n星期五\\n星期六", "ROLLER_MODE_NORMAL/INFINITE"], //选项第一个参数之间用 \\n 连接
    "align": "LABEL_ALIGN_LEFT/CENTER/RIGHT/AUTO",              //格式为：lvgl.LABEL_ALIGN_LEFT
    "selected": [2, "ANIM_ON"],                          //第一个参数为选项的下标，第二个参数是否有动画
    "visible_row_count": 4,
//部位：    lvgl.ROLLER_PART_BG/SELECTED
    ...
},
*/
function lvglRollerSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "options") {
                strCode += "\x09lvgl.roller_set_" + temVal + "(" + name + ", \"" + tar[val][0] + "\", lvgl." + tar[val][1] + ")\n";
            } else if (temVal === "align") {
                strCode += "\x09lvgl.roller_set_align(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "selected") {
                strCode += "\x09lvgl.roller_set_selected(" + name + ", " + tar[val][0] + ", lvgl." + tar[val][1] + ")\n";
            } else if (temVal === "anim_time" || temVal === "auto_fit" || temVal === "visible_row_count") {
                strCode += "\x09lvgl.roller_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "range": [0, 100],
    "anim_time": 4000,
    "type": "NORMAL/SYMMETRICAL/RANGE",         //格式为：lvgl.SLIDER_TYPE_NORMAL
    "value": [70, "ON"],
    "left_value": [30, "ON"],                   //第二个参数为是否有动画
//部位：    lvgl.SLIDER_PART_BG/INDIC/KNOB
    ...
},
*/
function lvglSliderSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "type") {
                strCode += "\x09lvgl.slider_set_type(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "anim_time") {
                strCode += "\x09lvgl.slider_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    for (let val2 in tar) {
        if (isValueNotNull(tar[val2])) {
            let temVal = transStrForamt(val2);
            if (temVal === "range") {
                strCode += "\x09lvgl.slider_set_range(" + name + ", " + tar[val2][0] + ", " + tar[val2][1] + ")\n";
            }
        }
    }
    for (let val3 in tar) {
        if (isValueNotNull(tar[val3])) {
            let temVal = transStrForamt(val3);
            if (temVal === "left_value" || temVal === "value") {
                strCode += "\x09lvgl.slider_set_" + temVal + "(" + name + ", " + tar[val3][0] + ", lvgl." + tar[val3][1] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "anim_time": 1000,
    "status": ["ON", "ANIM_ON"],                //第一个参数开关的开启、关闭状态，第二个参数是否有动画
//部位：    lvgl.SWITCH_PART_BG/INDIC/KNOB
    ...
},
*/
function lvglSwitchSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "status") {
                if (tar[val][0] === "ON") {
                    strCode += "\x09lvgl.switch_on(" + name + ", lvgl." + tar[val][1] + ")\n";
                } else {
                    strCode += "\x09lvgl.switch_off(" + name + ", lvgl." + tar[val][1] + ")\n";
                }
            } else if (temVal === "anim_time") {
                strCode += "\x09lvgl.switch_set_anim_time(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "type": "RECT/DISC",                        //格式为：lvgl.CPICKER_TYPE_RECT
    "hue": 300,                                 //0-360
    "saturation": 50,                           //0-100
    "color": "0xFF0000",
    "color_mode": "HUE/SATURATION/VALUE",       //lvgl.CPICKER_COLOR_MODE_HUE
    "color_mode_fixed": true/false,
    "knob_colored": true/false,
//部位：    lvgl.CPICKER_PART_MAIN/KNOB
    ...
},
*/
function lvglCpickerSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (val === "type") {
                strCode += "\x09lvgl.cpicker_set_type(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (val === "color") {
                tar[val] = tar[val].replace("#", "0x");
                strCode += "\x09lvgl.cpicker_set_color(" + name + ", lvgl.color_hex(" + tar[val] + "))\n";
            } else if (temVal === "color_mode") {
                strCode += "\x09lvgl.cpicker_set_color_mode(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "saturation" || temVal === "color_mode_fixed" || temVal === "knob_colored" || temVal === "hue") {
                strCode += "\x09lvgl.cpicker_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "needle_count": ["0xFF0000", "0x00FF00"],   //颜色数组, 暂时只支持一个元素
    "value": [[a, b], [a, b]],                  //a:针的下标， b：针的值   //lua下标从1开始
    "range": [0, 360],                          //可显示数值范围
    "critical_value": 270,
    "scale": [a, b, c],                         //a: 可移动度数, b: 刻度线数, c: 大刻度线数
    "angle_offset": 60,                         //偏转度数
//部位：    lvgl.GAUGE_PART_MAIN/MAJOR/NEEDLE
    ...
},
*/
function lvglGaugeSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "needle_count") {
                let len = tar[val].length;
                if (len === 1) {
                    tar[val][0] = (tar[val][0]).replace("#", "0x");
                    strCode += "\x09lvgl.gauge_set_needle_count(" + name + ", 1, lvgl.color_hex(" + tar[val][0] + "))\n";
                } else {
                    strCode += "\x09lvgl.gauge_set_needle_count(" + name + ", " + len + ", {";
                    for (let i = 0; i < len; i++) {
                        tar[val][i] = tar[val][i].replace("#", "0x");
                        if (i + 1 === len) {
                            strCode += "\x09lvgl.color_hex(" + tar[val][i] + ")})\n";
                        } else {
                            strCode += "\x09lvgl.color_hex(" + tar[val][i] + "), ";
                        }
                    }
                }
            } else if (val === "value") {
                let len = tar[val].length;
                for (let j = 0; j < len; j++) {
                    strCode += "\x09lvgl.gauge_set_value(" + name + ", " + tar[val][j][0] + ", " + tar[val][j][1] + ")\n";
                }
            } else if (val === "range") {
                strCode += "\x09lvgl.gauge_set_range(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
            } else if (val === "scale") {
                strCode += "\x09lvgl.gauge_set_scale(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ", " + tar[val][2] + ")\n";
            } else if (temVal === "critical_value" || temVal === "angle_offset") {
                strCode += "\x09lvgl.gauge_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "needles"){
                let len  = tar[val].length;
                if (len === 0){
                    //不做操作
                } else if (len === 1){
                    tar[val][0]["color"] = (tar[val][0]["color"]).replace("#", "0x");
                    strCode += "\x09lvgl.gauge_set_needle_count(" + name + ", 1, lvgl.color_hex(" + tar[val][0]["color"] + "))\n";
                    strCode += "\x09lvgl.gauge_set_value(" + name + ", " + "1, " + tar[val][0]["value"] + ")\n";
                } else {
                    strCode += "\x09lvgl.gauge_set_needle_count(" + name + ", " + len + ", {";
                    for (let i = 0; i < len; i++){
                        let curNeed = tar[val][i];
                        let curNeedColor = curNeed["color"].replace("#", "0x");
                        if (i + 1 === len) {
                            strCode += "lvgl.color_hex(" + curNeedColor + ")})\n";
                        } else {
                            strCode += "lvgl.color_hex(" + curNeedColor + "), ";
                        }
                    }
                    for (let j = 0; j < len; j++){
                        let curNeed2 = tar[val][j];
                        strCode += "\x09lvgl.gauge_set_value(" + name + ", " + j + ", " + curNeed2["value"] + ")\n";
                    }
                }
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "text": "电影",
    "options": "金\\n木\\n水\\n火\\n土\\n日\\n月",
    "selected": 2,
    "dir": "DROPDOWN_DIR_LEFT/RIGHT/UP/DOWN",                    //格式为：lvgl.DROPDOWN_DIR_LEFT
    "max_height": 50,
    "symbol": "DOWN",
    "show_selected": true/false,
//部位：    lvgl.DROPDOWN_PART_MAIN/LIST/SCROLLBAR/SELECTED
    ...
},
*/
function lvglDropdownSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "options") {
                let newVal = tar[val].replace(/\n/g, "\\n");
                strCode += "\x09lvgl.dropdown_set_" + temVal + "(" + name + ", \"" + newVal + "\")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "text") {
                strCode += "\x09lvgl.dropdown_set_" + temVal + "(" + name + ", \"" + tar[val] + "\")\n";
            } else if (temVal === "dir") {
                strCode += "\x09lvgl.dropdown_set_dir(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "symbol") {
                if (tar[val] === "nil") {
                    strCode += "\x09lvgl.dropdown_set_symbol(" + name + ", lvgl.SYMBOL_" + tar[val] + ")\n";
                } else {
                    strCode += "\x09lvgl.dropdown_set_symbol(" + name + ", " + tar[val] + ")\n";
                }
            } else if (temVal === "show_selected" || temVal === "max_height" || temVal === "selected") {
                strCode += "\x09lvgl.dropdown_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "range": [0, 360],              //表盘的度数范围
    "scale": [360, 12],             //第一个参数表盘的刻度数，第二个是刻度线数
    "angle_offset": 0,              //表盘的偏转角度
    "mirror": true/false,           //表盘的方向，true为逆时针, false为顺时针
    "value": 80,                    //当前表盘针的指向值
//部位：    lvgl.LINEMETER_PART_MAIN
    ...
},
*/
function lvglLineMeterSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        let temVal = transStrForamt(val);
        if (val === "range" || val === "scale") {
            strCode += "\x09lvgl.linemeter_set_" + val + "(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
        } else {
            strCode += "\x09lvgl.linemeter_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "scrollbar_mode": "OFF/ON/DRAG/AUTO/HIDE/UNHIDE",     //格式为： lvgl.SCROLLBAR_MODE_OFF
    "scroll_propagation": true/false,                   //启动滚动传播
    "edge_flash": true/false,                           //启动边缘闪光
    "anim_time": 50,
    "add_btn": [["FILE", "NEW1"], ["FILE", "NEW2"]],    //其中元素参数1为： 按钮图标，参数2为：按钮文字说明
//部位：    lvgl.LIST_PART_BG/SCROLLBAR/EDGE_FLASH/SCROLLABLE
    ...
},
*/
function lvglListSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        let temVal = transStrForamt(val);
        if (temVal === "scrollbar_mode") {
            strCode += "\x09lvgl.list_set_scrollbar_mode(" + name + ", lvgl.SCROLLBAR_MODE_" + tar[val] + ")\n";
        } else if (temVal === "add_btn") {
            for (let i = 0; i < tar[val].length; i++) {
                strCode += "\x09lvgl.list_add_btn(" + name + ", lvgl.SYMBOL_" + tar[val][i][0] + ", \"" + tar[val][i][1] + "\")\n";
            }
        } else {
            strCode += "\x09lvgl.list_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "arc_length": 360,
    "spin_time": 3000,
    "type": "SPINNING/FILLSPIN/CONSTANT",       //格式为： lvgl.SPINNER_TYPE_SPINNING_ARC
    "dir": "FORWARD/BACKWARD",
//部位：    lvgl.SPINNER_PART_BG/INDIC
    ...
},
*/
function lvglSpinnerSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (val === "type") {
            strCode += "\x09lvgl.spinner_set_type(" + name + ", lvgl.SPINNER_TYPE_" + tar[val] + "_ARC)\n";
        } else if (val === "dir") {
            strCode += "\x09lvgl.spinner_set_dir(" + name + ", lvgl.SPINNER_DIR_" + tar[val] + ")\n";
        } else {
            strCode += "\x09lvgl.spinner_set_" + val + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*

/*
特有属性格式
"comConf": {
    "rollover": true/false,
    "digit_format": [a, b],             //a位数：不包含小数点和符号
                                        //b小数点前的位数：如果为 0，则不显示小数点
    "step": 1,                          //步数
    "range": [0, 100],                  //数值的范围
    "value": 
//部位：    lvgl.SPINBOX_PART_BG/CURSOR
    ...
},
*/
function lvglSpinboxSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (val === "digit_format" || val === "range") {
            strCode += "\x09lvgl.spinbox_set_" + val + "(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
        } else {
            strCode += "\x09lvgl.spinbox_set_" + val + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "map":["1", "3", "\n", "5", ""],                //最后一个字符必须为 ""
    // "ctrl_map":
    "focused_btn": 2,
    "recolor": true/false,
    "btn_ctrl": [2, "NO_REPEAT"],                   //格式为 lvgl.BTNMATRIX_CTRL_HIDDEN
        //attr： HIDDEN/NO_REPEAT/DISABLED/CHECKABLE/CHECK_STATE/CLICK_TRIG
    "btn_ctrl_all": "NO_REPEAT",
    "btn_width": [1, 30],
    "align": "LEFT/CENTER/RIGHT/AUTO",              //格式为：lvgl.LABEL_ALIGN_LEFT
//部位：    lvgl.BTNMATRIX_PART_BG/BTN
    ...
},
*/
function lvglBtnMatrixSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        let temVar = name.slice(name.indexOf(".") + 1)
        temVar = temVar.replace("." + objectSelf, "");
        if (val === "btn_ctrl") {
            strCode += "\x09lvgl.btnmatrix_set_btn_ctrl(" + name + ", " + tar[val][0] + ", lvgl.BTNMATRIX_CTRL_" + tar[val][1] + ")\n";
        } else if (val === "map") {
            strCode += "\x09" + "map" + temVar + " = {";
            for (let i = 0; i < tar[val].length; i++) {
                if (i + 1 === tar[val].length) {
                    strCode += "\"" + tar[val][i] + "\"}\n";
                } else {
                    if (tar[val][i] === "\n") {
                        strCode += "\"\\n\", ";
                    } else {
                        strCode += "\"" + tar[val][i] + "\", ";
                    }
                }
            }
            strCode += "\x09lvgl.btnmatrix_set_map(" + name + ", map" + temVar + ")\n";
        } else if (val === "btn_ctrl_all") {
            strCode += "\x09lvgl.btnmatrix_set_btn_ctrl_all(" + name + ", lvgl.BTNMATRIX_CTRL_" + tar[val] + ")\n";
        } else if (val === "align") {
            strCode += "\x09lvgl.btnmatrix_set_align(" + name + ", lvgl.LABEL_ALIGN_" + tar[val] + ")\n";
        } else if (val === "btn_width") {
            strCode += "\x09lvgl.btnmatrix_set_btn_width(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
        } else {
            strCode += "\x09lvgl.btnmatrix_set_" + val + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*
图表的数据可视化动画
@chart:                 图表的名字
@data:                  数据
@animation:             动画间隔
*/
function lvglChartAnimSpe(chart, data, animTime) {
    let strCode = "";

    strCode += "\x09sys.taskInit(function()\n";
    strCode += "\x09\x09while true do\n";
    strCode += "\x09\x09\x09\nsys.wait(" + animTime + ")\n";

    return strCode;
}

/*
特有属性格式
"comConf": {
    "type": "CHART_TYPE_NONE/LINE/COLUMN",            //格式为：lvgl.CHART_TYPE_NONE
    "div_line_count": [20, 20],                       //设置图表的横纵线条数
    "update_mode": "CHART_UPDATE_MODE_SHIFT/CIRCULAR" //格式为：lvgl.CHART_UPDATE_MODE_SHIFT
    "y_range": ["PRIMARY_Y/SECONDARY_Y", 0, 100],     //设置y轴的数值范围
                                                      //格式为：lvgl.CHART_AXIS_PRIMARY_Y
    "series": [
        {
            "color": "#00FF00",
            "points": [
                1,
                15,
                3,
                4
            ]
        }, ...
    ],  //设置图表的数据
    "pointCount": 100,                                //设置图表的数据点数量
    "yTick": {                                        //设置图表的y轴刻度
        "text": "1\n2\n3\n4\n5",
        "num": 2,
        "major": 12,
        "minor": 3
    },
    "xTick": {                                        //设置图表的x轴刻度
        "text": "6\n7\n8\n9",
        "num": 2,
        "minor": 5
    },
//部位：    lvgl.CHART_PART_BG/SERIES_BG/SERIES/CURSOR
    ...
},
*/
function lvglChartSpe(name, tar) {
    let temName = name.match(/(?<=\.)\w+(?=\.)/)[0];
    let strCode = "";
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "type") {
                strCode += "\x09lvgl.chart_set_type(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "div_line_count") {
                strCode += "\x09lvgl.chart_set_div_line_count(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
            } else if (temVal === "update_mode") {
                strCode += "\x09lvgl.chart_set_update_mode(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "y_range") {
                if (tar[val][0].length === 3) {
                    strCode += "\x09lvgl.chart_set_y_range(" + name + ", lvgl.CHART_AXIS_" + tar[val][0] + ", " + tar[val][1] + ", " + tar[val][2] + ")\n";
                }
            } else if (temVal === "y_tick" || temVal === "x_tick") {
                if (isValueNotNull(tar[val]["major"]) && isValueNotNull(tar[val]["minor"])) {
                    strCode += "\x09lvgl.chart_set_" + temVal + "_length(" + name + ", " + tar[val]["major"] + ", " + tar[val]["minor"] + ")\n";
                }
                if (isValueNotNull(tar[val]["text"]) && isValueNotNull(tar[val]["num"]) && isValueNotNull(tar[val]["axis"])) {
                    strCode += "\x09lvgl.chart_set_" + temVal + "_texts(" + name + ", " + tar[val]["text"] + ", " + tar[val]["num"] + ", " + tar[val]["axis"] + ")\n";
                }
            } else if (temVal === "point_count") {
                strCode += "\x09lvgl.chart_set_point_count(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "series") {
                for (let i = 0; i < tar[val].length; i++) {
                    let tem = i + 1;
                    let color = tar[val][i]["color"].replace("#", "0x");
                    strCode += "\x09" + "color_" + temName + "_" + tem + " = lvgl.chart_add_series(" + name +
                        ", lvgl.color_hex(" + color + "))\n";
                    for (let j = 0; j < tar[val][i]["points"].length; j++){
                        strCode += "\x09lvgl.chart_set_next(" + name + ", color_" + temName + "_" + tem + ", " + tar[val][i]["points"][j] + ")\n";
                    }
                }
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "layout":   "OFF/CENTER/COLUMN_LEFT/COLUMN_MID/COLUMN_RIGHT/
                ROW_TOP/ROW_MID/ROW_BOTTOM/PRETTY_TOP/PRETTY_MID/
                PRETTY_BOTTOM/GRID",                                 //格式为： lvgl.LAYOUT_OFF
    "fit4": ["lay1", "lay2", "lay3", "lay4"],
    "fit2": ["lay1", "lay2"],
    "fit": "lay1",                        //格式为： 上述的lay和layout中的字符一样
//部位：    lvgl.CONT_PART_MAIN
    ...
},
*/
function lvglContSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (val === "layout") {
            strCode += "\x09lvgl.cont_set_layout(" + name + ", lvgl." + tar[val] + ")\n";
        } else if (val === "fit") {
            strCode += "\x09lvgl.cont_set_fit(" + name + ", lvgl." + tar[val] + ")\n";
        } else if (val === "fit2") {
            strCode += "\x09lvgl.cont_set_fit2(" + name + ", lvgl." + tar[val][0] + ", lvgl." + tar[val][1] + ")\n";
        } else if (val === "fit4") {
            strCode += "\x09lvgl.cont_set_fit4(" + name + ", lvgl." + tar[val][0] + ", lvgl." + tar[val][1] +
                ", lvgl." + tar[val][2] + ", lvgl." + tar[val][3] + ")\n";
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "row_cnt": 3,
    "col_cnt": 2,
    "cell_align": [[0, 0, "CENTER"], [0, 1, "AUTO"],        //格式为： lvgl.LABEL_ALIGN_LEFT
                    [1, 0, "LEFT"], [1, 1, "RIGHT"]],       //设置单元格的对齐方式，每个元素对应一个单元格
    "type": [[1, 0, 1], [1, 1, 2], [2, 0, 3], [2, 1, 4]],
    "cell_merge_right": [1, 0, true/false],                         //把设置的单元格的右边的单元格合并并去除显示
    "cell_value": [[0, 0, "名称"], [0, 1, "物品"], [1, 0, "哈哈"], 
                    [1, 1, "球"], [2, 0, "呵呵"], [2, 1, "枪"]],    //设置单元格的内容，每个元素对应一个单元格
//部位：    lvgl.TABLE_PART_BG/CELL1/CELL2/CELL3/CELL4
    ...
    table 现如今无法设置单元格背景的样式，只能文字的颜色
*/
function lvglTableSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (val.includes("cnt")) {
            strCode += "\x09lvgl.table_set_" + val + "(" + name + ", " + tar[val] + ")\n";
        } else if (val === "cell_align") {
            for (let i = 0; i < tar[val].length; i++) {
                strCode += "\x09lvgl.table_set_cell_align(" + name + ", " + tar[val][i][0] + ", " +
                    tar[val][i][1] + ", lvgl.LABEL_ALIGN_" + tar[val][i][2] + ")\n";
            }
        } else if (val === "type") {
            for (let j = 0; j < tar[val].length; j++) {
                strCode += "\x09lvgl.table_set_cell_type(" + name + ", " + tar[val][j][0] + ", " +
                    tar[val][j][1] + ", " + tar[val][j][2] + ")\n";
            }
        } else if (val === "cell_merge_right") {
            strCode += "\x09lvgl.table_set_cell_merge_right(" + name + ", " + tar[val][0] + ", " +
                tar[val][1] + ", " + tar[val][2] + ")\n";
        } else if (val.includes("value")) {
            for (let k = 0; k < tar[val].length; k++) {
                strCode += "\x09lvgl.table_set_cell_value(" + name + ", " + tar[val][k][0] + ", " +
                    tar[val][k][1] + ", \"" + tar[val][k][2] + "\")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "scrollbar_mode": "OFF/ON/DRAG/AUTO/HIDE/UNHIDE",   //格式为： lvgl.SCROLLBAR_MODE_OFF
    "anim_time": 1000,
    "scroll_propagation": true/false,                   //设置true要确保父级可以滑动
    "edge_flash": true/false,
    "scrl_width": 200,
    "scrl_height": 200,
    "scrl_layout":   "OFF/CENTER/COLUMN_LEFT/COLUMN_MID/COLUMN_RIGHT/
                ROW_TOP/ROW_MID/ROW_BOTTOM/PRETTY_TOP/PRETTY_MID/
                PRETTY_BOTTOM/GRID",                                 //格式为： lvgl.LAYOUT_OFF
//部位：    lvgl.PAGE_PART_BG/SCROLLBAR/EDGE_FLASH/SCROLLABLE
    ...
},
*/
function lvglPageSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (val === "scrollbar_mode") {
            strCode += "\x09lvgl.page_set_scrollbar_mode(" + name + ", lvgl.SCROLLBAR_MODE_" + tar[val] + ")\n";
        } else if (val === "scrl_layout") {
            strCode += "\x09lvgl.page_set_scrl_layout(" + name + ", lvgl.LAYOUT_" + tar[val] + ")\n";
        } else {
            strCode += "\x09lvgl.page_set_" + val + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "anim_time": 500,
    "btns_pos": "NONE/TOP/BOTTOM/LEFT/RIGHT",               //格式为： lvgl.TABVIEW_TAB_POS_NONE
    "add_tab": ["first", "second", "third"],
    "tab_act": [1, "ON/OFF"],                               //格式为:  lvgl.ANIM_ON
    "page": [                                               //添加一个属性page用来设置tabview中页面的属性
        {
            "first": {
            属性和page控件里面的一样，目前不支持内部添加样式
            }
        },
        {
            "second": {
                属性和page控件里面的一样，目前不支持内部添加样式
            },
        },...
    ]
//部位：    lvgl.TABVIEW_PART_BG/BG_SCROLLABLE/TAB_BG/TAB_BTN/INDIC
    ...
},
*/
function lvglTableViewSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        let temVar = name.slice(name.indexOf(".") + 1)
        temVar = temVar.replace("." + objectSelf, "");
        if (val === "anim_time") {
            strCode += "\x09lvgl.tabview_set_anim_time(" + name + ", " + tar[val] + ")\n";
        } else if (val === "btns_pos") {
            strCode += "\x09lvgl.tabview_set_btns_pos(" + name + ", lvgl.TABVIEW_TAB_POS_" + tar[val] + ")\n";
        } else if (val === "add_tab") {
            for (let i = 0; i < tar[val].length; i++) {
                strCode += "\x09tab" + temVar + "_" + i + " = lvgl.tabview_add_tab(" + name + ", \"" + tar[val][i] + "\")\n";
            }
        } else if (val.includes("act")) {
            strCode += "\x09lvgl.tabview_set_tab_act(" + name + ", " + tar[val][0] + ", lvgl.ANIM_" + tar[val][1] + ")\n";
        } else if (val === "page") {
            for (let j = 0; j < tar[val].length; j++) {
                for (let key in tar[val][j]) {
                    let temName = "tab" + temVar + "_" + j;
                    strCode += lvglPageSpe(temName, tar[val][j][key]);
                }
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "title": ""
    "header_height": 50,
    "btn_right": "lvgl.SYMBOL_CLOSE/("/lua/kl.img")",   //完整确定的图源地址或者内置文字符号
    "btn_left": "lvgl.SYMBOL_CLOSE/("/lua/kl.img")",    //完整确定的图源地址或者内置文字符号
    "btn_width": 80,
    "scrollbar_mode": "OFF/ON/DRAG/AUTO/HIDE/UNHIDE",   //格式为： lvgl.SCROLLBAR_MODE_OFF
    "layout":   "OFF/CENTER/COLUMN_LEFT/COLUMN_MID/COLUMN_RIGHT/
                ROW_TOP/ROW_MID/ROW_BOTTOM/PRETTY_TOP/PRETTY_MID/
                PRETTY_BOTTOM/GRID",                                 //格式为： lvgl.LAYOUT_OFF
    "content_size": [400, 600],
    "drag": true/false,
    "alignment": 0/1/2/4/8/16,    //依次表示不设置/重新着色/扩展/居中/居右/自适应
//部位：    lvgl.WIN_PART_BG/HEADER/CONTENT_SCROLLABLE/SCROLLBAR
    ...
},
*/
function lvglWindowSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (val === "anim_time" || val === "header_height" || val === "btn_width" || val === "drag" || val === "title" || val === "alignment") {
            if (val === "title") {
                strCode += "\x09lvgl.win_set_" + val + "(" + name + ", \"" + tar[val] + "\")\n";
            } else if (val === "alignment") {
                strCode += "\x09lvgl.win_title_set_alignment(" + name + ", " + tar[val] + ")\n";
            } else {
                strCode += "\x09lvgl.win_set_" + val + "(" + name + ", " + tar[val] + ")\n";
            }
        } else if (val.includes("mode")) {
            strCode += "\x09lvgl.win_set_scrollbar_mode(" + name + ", lvgl.SCROLLBAR_MODE_" + tar[val] + ")\n";
        } else if (val === "layout") {
            strCode += "\x09lvgl.win_set_layout(" + name + ", lvgl.LAYOUT_" + tar[val] + ")\n";
        } else if (val === "content_size") {
            strCode += "\x09lvgl.win_set_content_size(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
        } else if (val.includes("btn")) {
            strCode += "\x09lvgl.win_add_" + val + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "points": [[1, 1], [2, 2], [3, 3], [4, 4]],
    "auto_size": true/false,                    //启用自动调整大小
    "y_invert": true/false,                     //设置y坐标反转
//部位：    lvgl.LINE_PART_MAIN
    ...
    暂时此控件无法使用
},
*/
function lvglLineSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (val === "points") {
            strCode += "\x09" + "point_" + name + " = {";
            for (let i = 0; i < tar[val].length; i++) {
                strCode += "{" + tar[val][i][0] + ", " + tar[val][i][1] + "}, "
            }
            strCode += "}\n\x09lvgl.line_set_points(" + name + ", point_" + name + ", " + tar[val].length + ")\n";
        } else {
            strCode += "\x09lvgl.line_set_" + val + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "text": "大航海",
    "placeholder_text": "请输入：",
    "cursor_pos": 8,                                    //范围 <0 新坐标， > 0 末尾
    "cursor_hidden": true/false,
    "cursor_click_pos": true/false,
    "pwd_mode": true/false,
    "one_line": true/false,
    "text_align": "LEFT/CENTER/RIGHT/AUTO",             //格式为： lvgl.LABEL_ALIGN_LEFT
    "accepted_chars": "0123456789",                     //设置接受的字符
    "max_length": 30,
    "scrollbar_mode": "OFF/ON/DRAG/AUTO/HIDE/UNHIDE",   //格式为： lvgl.SCROLLBAR_MODE_OFF
    "scroll_propagation": true/false,
    "edge_flash": true/false,
    "text_sel": true/false,
    "pwd_show_time": 1000,
    "cursor_blink_time": 200,
    //此处为设计器人为添加的属性
    "keyboard":{                        //为输入框添加键盘,此处定义键盘的属性
        "size": [400, 200],             //键盘的大小
        "align": [0, 10],               //键盘相对于输入框的底部的对齐距离
    }
    //部位：    lvgl.TEXTAREA_PART_BG/SCROLLBAR/EDGE_FLASH/CURSOR/PLACEHOLDER
    ...
},
*/
function lvglTextAreaSpe(name, tar) {
    let strCode = "";
    let temVar = name.slice(name.indexOf(".") + 1)
    temVar = temVar.replace("." + objectSelf, "");
    for (let val in tar) {
        if (isValueNotNull(tar[val]) || val === "text") {
            let temVal = transStrForamt(val);
            if (temVal === "placeholder_text" || temVal === "accepted_chars" || temVal === "text") {
                let newVal = disStringEscape(tar[val]);
                strCode += "\x09lvgl.textarea_set_" + temVal + "(" + name + ", \"" + newVal + "\")\n";
            } else if (temVal === "text_align") {
                strCode += "\x09lvgl.textarea_set_text_align(" + name + ", lvgl.LABEL_ALIGN_" + tar[val] + ")\n";
            } else if (temVal === "scrollbar_mode") {
                strCode += "\x09lvgl.textarea_set_scrollbar_mode(" + name + ", lvgl.SCROLLBAR_MODE_" + tar[val] + ")\n";
            } else if (temVal === "keyboard") {
                let pos_x = 0,
                    pos_y = 0,
                    width = 0,
                    height = 0;
                for (let key in tar[val]) {
                    if (key === "size") {
                        width = tar[val][key][0];
                        height = tar[val][key][1];
                    }
                    if (key === "align") {
                        pos_x = tar[val][key][0];
                        pos_y = tar[val][key][1];
                    }
                }
                let keyName = "keyboard_" + temVar;
                strCode += "\x09" + "keyCb_" + temVar + " = function(obj, e)\n" + "\x09\x09if (e == lvgl.EVENT_CLICKED)then\n" +
                    "\x09\x09\x09" + keyName + " = lvgl.keyboard_create(lvgl.scr_act(), nil)\n" +
                    "\x09\x09\x09lvgl.obj_set_size(" + keyName + ", " + width + ", " + height + ")\n" +
                    "\x09\x09\x09lvgl.keyboard_set_textarea(" + keyName + ", obj)\n" +
                    "\x09\x09\x09lvgl.obj_align(" + keyName + ", obj, lvgl.ALIGN_OUT_BOTTOM_MID, " + pos_x + ", " + pos_y + ")\n\x09\x09end\n\x09end\n" +
                    "\x09lvgl.obj_set_event_cb(" + name + ", keyCb_" + temVar + ")\n";
            } else if (temVal === "cursor_hidden" || temVal === "pwd_mode" || 
                        temVal === "one_line" || temVal === "edge_flash" || 
                        temVal === "pwd_show_time" || temVal === "cursor_blink_time" || temVal == "max_length") {
                strCode += "\x09lvgl.textarea_set_" + temVal + "(" + name + ", " + tar[val] + ")\n";
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
            "mode": "KEYBOARD_MODE_NUM",    //lvgl.KEYBOARD_MODE_TEXT_LOWER
            "textarea": "textInput"         //keyboady 对应的输出控件
//部位：    lvgl.KEYBOARD_PART_BG/BTN
},
*/
function lvglKeyBoardSpe(name, tar){
    let strCode = "";
    let isNeedTextarea = false;
    let whichScr = name.match(/^\w+\./);
    let par;
    for (let val in tar) {
        if (isValueNotNull(tar[val])) {
            let temVal = transStrForamt(val);
            if (temVal === "mode") {
                strCode += "\x09lvgl.keyboard_set_mode(" + name + ", lvgl." + tar[val] + ")\n";
            } else if (temVal === "textarea") {
                isNeedTextarea = true;
                par = whichScr + tar[val] + ".self";
                strCode += "\x09lvgl.keyboard_set_textarea(" + name + ", " + whichScr + tar[val] + ".self)\n";
            } else if (val === "hiddenKeyboard"){
                if (tar[val]) {
                    strCode += "\x09lvgl.obj_set_hidden(" + name + ", true)\n";
                }
            }
        }
    }
    if (isNeedTextarea){
        strCode += "\x09local outputCb = function(o, e)\n";
        strCode += "\x09\x09lvgl_UiDesigner_DefOutCb(o, e, " + name + ")\n";
        strCode += "\x09end\n";
        strCode += "\x09lvgl.obj_set_event_cb(" + par + ", outputCb)\n";
    }
    strCode += "\x09lvgl.obj_set_event_cb(" + name + ", lvgl_UiDesigner_DefInCb)\n";
    return strCode;
}

/*
特有属性格式
"comConf": {
    "src": "/lua/tar.bmp",              //外部图片或者lvgl内部文字图片，注意文字图片无法进行缩放
    "auto_size": true/false,
    "offset_x": 30,
    "offset_y": 30,
    "pivot": [0, 0],                    //设置旋转中心
    "angle": 30,
    "zoom": 256/<256/>256,              //格式：256为不缩放, <256: 缩小, >256: 放大
    "antialias": true/false,            //启用抗锯齿
//部位：    lvgl.IMG_PART_MAIN
    ...
},
*/
function lvglImgSpe(name, tar, imageBase) {
    let strCode = "";
    for (let val in tar) {
        let temVal = transStrForamt(val);
        if (temVal === "pivot") {
            strCode += "\x09lvgl.img_set_" + val + "(" + name + ", " + tar[val][0] + ", " + tar[val][1] + ")\n";
        } else if (temVal === "src") {
            if (tar[val].slice(0, 6) === "lvgl.S") {
                strCode += "\x09lvgl.img_set_" + val + "(" + name + ", " + tar[val] + ")\n";
            } else {
                let pt = getStringLastEcString(tar[val]);
                if (pt){
                    if (isSoc) {
                        strCode += "\x09lvgl.img_set_" + val + "(" + name + ", \"/" + pt + "\")\n";
                    } else {
                        strCode += "\x09lvgl.img_set_" + val + "(" + name + ", \"/lua/" + pt + "\")\n";
                    }
                    let temProp = lvglGetImageResScale(tar[val], imageBase);
                    if (temProp) {
                        strCode += "\x09lvgl.img_set_zoom(" + name + ", " + temProp + ")\n";
                        strCode += "\x09lvgl.img_set_pivot(" + name + ", 0, 0)\n";
                    }
                }
            }
        } else if (temVal === "auto_size" || temVal === "offset_x" || temVal === "offset_y" ||
            temVal === "angle" || temVal === "zoom" || temVal === "antialias") {
            strCode += "\x09lvgl.img_set_" + val + "(" + name + ", " + tar[val] + ")\n";
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
    "src": {
        "RELEASED": "/lua/a.img",
        "PRESSED": "lvgl.SYMBOL_CLOSE",
        ...                         //格式为： lvgl.BTN_STATE_RELEASED
                                    //总共有如下状态:
                                    //RELEASED/PRESSED/DISABLED/CHECKED_RELEASED/CHECKED_PRESSED/CHECKED_DISABLED
    }
//部位：    lvgl.IMGBTN_PART_MAIN
    ...
},
*/
function lvglImgBtnSpe(name, tar) {
    let strCode = "";
    for (let val in tar) {
        if (val === "src") {
            for (let key in tar[val]) {
                if (tar[val][key].slice(0, 6) === "lvgl.S") {
                    strCode += "\x09lvgl.imgbtn_set_" + val + "(" + name + ", lvgl.BTN_STATE_" + key + ", " + tar[val][key] + ")\n";
                } else {
                    let temKey = (transStrForamt(key)).toUpperCase();
                    let pt = getStringLastEcString(tar[val][key]);
                    if (pt){
                        if (isSoc) {
                            strCode += "\x09lvgl.imgbtn_set_" + val + "(" + name + ", lvgl.BTN_STATE_" + temKey + ", \"/" + pt + "\")\n";
                        } else {
                            strCode += "\x09lvgl.imgbtn_set_" + val + "(" + name + ", lvgl.BTN_STATE_" + temKey + ", \"/lua/" + pt + "\")\n";
                        }
                    }
                }
            }
        }
    }
    return strCode;
}

/*
特有属性格式
"comConf": {
//部位：    lvgl.OBJ_PART_MAIN
    ...
},
*/
function lvglObjSpe(name, tar) {
    let strCode = "";
    let val;
    for (val in tar) {

    }
    return strCode;
}

/*
 ******************************************************************************************************************************
 ************************************************以下为转换json数据为具体的 lua 代码*********************************************
 ******************************************************************************************************************************
 */

/*
初始化控件的大小，位置，对齐
@tar                    为json数据中的 base 对象
@name                   控件的名称
@type                   设置的模式: 1: 设置大小 2：设置位置和对齐
@return                 设置控件大小，位置，对齐的代码块
*/
function lvglwidBase(tar, name, type, alignFather) {
    // console.log("tarBase", tar);
    let baseStr = "";
    for (let val in tar) {
        if (type === 1) {
            if (val === "width") {
                baseStr += "\x09lvgl.obj_set_size(" + name + widObjName + ", " + tar.width + ", " + tar.height + ")\n";
            }
        } else if (type === 2) {
            //判断是否是相对对齐
            if (val === "x") {
                if (tar.hasOwnProperty("align")) {
                    baseStr = baseStr.concat("\x09lvgl.obj_align(" + name + widObjName + ", " + alignFather + ", " + "lvgl.ALIGN_" + tar.align + ", " +
                        tar.x + ", " + tar.y + ")\n")
                } else {
                    baseStr = baseStr.concat("\x09lvgl.obj_align(" + name + widObjName + ", " + alignFather + ", " + "lvgl.ALIGN_IN_TOP_LEFT, " +
                        tar.x + ", " + tar.y + ")\n")
                }
            }
        } else {
            if (val === "width") {
                baseStr += "\x09lvgl.obj_set_width(" + name + widObjName + ", " + tar.width + ")\n";
            }
        }
    }
    return baseStr;
}

/*
为控件添加样式
@                       格式化json数据中的 style 对象
格式：
style: {
                'lvgl.ARC_PART_MAIN': {
                    'lvgl.STATE_DEFAULT': {
                        'lvgl.style_set_radius': 20,
                        'lvgl.style_set_bg_color': '0xFFFFFF',
                    },
                    styName: 'Style_schema3_1',
                    objName: 'blockA9'
                }
            }
*/
function lvglWidAddStyle(tar) {
    let strCode = "";
    let strHead = "\x09lvgl.obj_add_style(";
    for (let val in tar) {
        strCode += strHead + tar[val].objName + widObjName + ", " + val + ", " + tar[val].styName + ")\n"
    }
    return strCode;
}

/*
设置控件特有的属性
@tar
*/
function lvglwidAddSpe(type, tar, name, contBase, style) {
    let widSpeCode = "";
    name = name + widObjName;
    switch (type) {
        case "obj":
            widSpeCode += lvglObjSpe(name, tar);
            break;
        case "arc":
            widSpeCode += lvglArcSpe(name, tar);
            break;
        case "bar":
            widSpeCode += lvglBarSpe(name, tar);
            break;
        case "btn":
            widSpeCode += lvglBtnSpe(name, tar, style);
            break;
        case "btnmatrix":
            widSpeCode += lvglBtnMatrixSpe(name, tar);
            break;
        case "calendar":
            widSpeCode += lvglCalendarSpe(name, tar);
            break;
        case "checkbox":
            widSpeCode += lvglCheckBoxSpe(name, tar);
            break;
        case "chart":
            widSpeCode += lvglChartSpe(name, tar);
            break;
        case "cont":
            widSpeCode += lvglContSpe(name, tar);
            break;
        case "cpicker":
            widSpeCode += lvglCpickerSpe(name, tar);
            break;
        case "dropdown":
            widSpeCode += lvglDropdownSpe(name, tar);
            break;
        case "gauge":
            widSpeCode += lvglGaugeSpe(name, tar);
            break;
        case "img":
            widSpeCode += lvglImgSpe(name, tar, contBase);
            break;
        case "imgbtn":
            widSpeCode += lvglImgBtnSpe(name, tar);
            break;
        case "textarea":
            widSpeCode += lvglTextAreaSpe(name, tar);
            break;
        case "keyboard":
            widSpeCode += lvglKeyBoardSpe(name, tar);
            break;
        case "label":
            widSpeCode += lvglLabelSpe(name, tar, contBase);
            break;
        case "led":
            widSpeCode += lvglLedSpe(name, tar);
            break;
        case "line":
            widSpeCode += lvglLineSpe(name, tar);
            break;
        case "list":
            widSpeCode += lvglListSpe(name, tar);
            break;
        case "linemeter":
            widSpeCode += lvglLineMeterSpe(name, tar);
            break;
        case "msgbox":
            break;
        case "page":
            widSpeCode += lvglPageSpe(name, tar);
            break;
        case "roller":
            widSpeCode += lvglRollerSpe(name, tar);
            break;
        case "slider":
            widSpeCode += lvglSliderSpe(name, tar);
            break;
        case "spinbox":
            widSpeCode += lvglSpinboxSpe(name, tar);
            break;
        case "spinner":
            widSpeCode += lvglSpinnerSpe(name, tar);
            break;
        case "switch":
            widSpeCode += lvglSwitchSpe(name, tar);
            break;
        case "table":
            widSpeCode += lvglTableSpe(name, tar);
            break;
        case "tabview":
            widSpeCode += lvglTableViewSpe(name, tar);
            break;
        case "tileview":
            break;
        case "win":
            widSpeCode += lvglWindowSpe(name, tar);
            break;
        case "qrcode":
            widSpeCode += lvglQrcodeSpe(name, tar);
            break;
        default:
            console.log("The widgets that you inputs is error")
            break;
    }
    return widSpeCode;
}

/*
生成控件的基础要素
@tar                    控件属性对象
格式：
schema3: {
    base: { width: 100, height: 100, x: 79, y: 100, align: 'OUT_BOTTOM_MID' },
    type: 'arc',
    screen: 'sceneA',
    name: 'blockA9',
    style: {
        'lvgl.ARC_PART_MAIN': {
            'lvgl.STATE_DEFAULT': {
                'lvgl.style_set_radius': 20,
                'lvgl.style_set_bg_color': '0xFFFFFF',
                'lvgl.style_set_bg_opa': 0.8,
                'lvgl.style_set_bg_grad_color': '0xFFFFFF',
                'lvgl.style_set_bg_main_stop': 20,
                'lvgl.style_set_bg_grad_stop': 250,
                'lvgl.style_set_bg_grad_dir': 'HOR',
                'lvgl.style_set_bg_blend_mode': 'NORMAL',
                'lvgl.style_set_bg_op_y': 30
            },
            styName: 'Style_schema3_1',
            objName: 'blockA9'
        },
        ...
    },
    special: {
        type: 'SYMMETRICAL',
        range: [Array],
        start_value: [Array],
        anim_time: 5000,
        value: [Array]
    },
    event: { 
        CLICKED: 'clickedHandle1', 
        PRESSED: 'pressedHandle1' 
    }
}
*/
function lvglwidInit(tar) {
    let lvglStr = "lvgl.";
    //控件初始化
    let widBaseCode = "";
    //添加注释
    widBaseCode += "\n\n\x09--This is the base code of " + tar.name;
    //创建一个控件
    widBaseCode += "\n\x09" + tar.name + "." + objectSelf + " = " + lvglStr;
    widBaseCode = widBaseCode.concat(tar.type + "_create(" + tar["parent"] + ", ");
    widBaseCode = widBaseCode.concat("nil)\n");
    //设置控件的大小，位置，对齐
    if (tar.type === "img" || tar.type === "imgbtn") {
        //排除图片无需设置大小的情况
    } else  if (tar.type === "label" || tar.type === "dropdown") {//排除文字和下拉框设置高度无效的情况
        widBaseCode = widBaseCode.concat(lvglwidBase(tar.base, tar.name, 3, tar["parent"]));
    } else {
        widBaseCode = widBaseCode.concat(lvglwidBase(tar.base, tar.name, 1, tar["parent"]));
    }
    //为控件添加可以响应的事件回调功能
    widBaseCode += "\x09lvgl.obj_set_click(" + tar.name + widObjName + ", true)\n";
    //设置控件的特有属性
    widBaseCode += lvglwidAddSpe(tar.type, tar.special, tar.name, tar.base, tar.style);
    //设置控件的位置，对齐
    widBaseCode = widBaseCode.concat(lvglwidBase(tar.base, tar.name, 2, tar["parent"]));
    //添加样式
    widBaseCode += lvglWidAddStyle(tar.style);
    return widBaseCode;
}

/*
样式的参数格式化
@tar                参数组成的数组
@return             参数组成的代码块
*/
function lvglStyleFormatly(tar) {
    let str = "";
    switch (tar.length) {
        case 4:
            //对颜色进行格式化
            if (tar[0].includes("color")) {
                tar[3] = tar[3].replace("#", "0x");
                tar[3] = "lvgl.color_hex(" + tar[3] + ")";
            }
            //对混合模式进行格式化
            if (tar[0].includes("blend_mode")) {
                tar[3] = "lvgl.BLEND_MODE_" + tar[3];
            }
            //对文字中的修饰符进行格式化
            if (tar[0].includes("text_decor")) {
                tar[3] = "lvgl.TEXT_DECOR_" + tar[3];
            }
            //对背景的渐变方向进行格式化
            if (tar[0].includes("grad_dir")) {
                tar[3] = "lvgl.GRAD_DIR_" + tar[3];
            }
            //对文字中的设置字符串进行格式化
            if (tar[0].includes("value_str")) {
                tar[3] = "\"" + disStringEscape(tar[3]) + "\"";
            }
            //对文字的对齐方式进行格式化
            if (tar[0].includes("value_align")) {
                if (tar[3] === "CENTER") {
                    tar[3] = "lvgl.ALIGN_IN_" + tar[3];
                } else {
                    tar[3] = "lvgl.ALIGN_IN_BOTTOM_" + tar[3];
                }
            }
            //对边框中的设置边框的位置进行格式化
            if (tar[0].includes("border_side")) {
                if (tar[3].length > 0){
                    let temTar = "";
                    for (let i = 0; i < tar[3].length; i++){
                        if (i + 1 === tar[3].length){
                            temTar += "lvgl.BORDER_SIDE_" + tar[3][i];
                        } else {
                            temTar += "lvgl.BORDER_SIDE_" + tar[3][i] + " or ";
                        }
                    }
                    tar[3] = temTar;
                }
            }
            //对过渡的样式进行格式化
            if (tar[0].includes("prop")) {
                tar[3] = "lvgl." + tar[3];
            }
            /*
                            组合参数字符串
            */
            str = tar[1] + ", " + tar[2] + ", " + tar[3];
            break;
        default:
            break;
    }
    return str;
}

/*
生成控件的样式
@tar                    样式对象
格式：
{
    'lvgl.ARC_PART_MAIN': {
        'lvgl.STATE_DEFAULT': {
            'lvgl.style_set_radius': 20,
            'lvgl.style_set_bg_color': '0xFFFFFF',
            'lvgl.style_set_bg_opa': 0.8
            'lvgl.style_set_bg_grad_stop': 250,
            'lvgl.style_set_bg_grad_dir': 'HOR',
            'lvgl.style_set_bg_blend_mode': 'NORMAL',
            'lvgl.style_set_bg_op_y': 30
        },
        styName: 'Style_schema3_1',
        objName: 'blockA9'
    },
    ...
}
...
*/
function lvglWidStyleInit(tar) {
    let styleObj = tar.style;
    let allStyleCode = "";
    //获取控件下的不同部位
    for (let part in styleObj) {
        let o = part.slice(5);
        allStyleCode += "\n\n\x09--This is the " + o + "'s style of " + styleObj[part].objName;
        let styleName = styleObj[part].styName;
        let styleCode = styleName;
        styleCode = "\n\x09" + styleCode + " = lvgl.style_t()";
        styleCode += "\n\x09lvgl.style_init(" + styleName + ")";
        //获取部位下的不同状态
        for (let status in styleObj[part]) {
            if (status.includes("STATE")) {
                //获取状态下的样式
                for (let sCode in styleObj[part][status]) {
                    let tem = styleObj[part][status];
                    //样式名称 + 状态 + 具体的属性值
                    //排除是否是设置过渡样式
                    if (sCode.includes("prop")) {
                        for (let i = 0; i < tem[sCode].length; i++) {
                            let temI = i + 1;
                            if (temI > 4) {
                                temI = 4;
                            }
                            let temName = sCode + "_" + temI;
                            let para = lvglStyleFormatly([sCode, styleName, status, tem[sCode][i]]);
                            styleCode += "\n\x09" + temName + "(" + para + ")";
                        }
                        //排除是否是边框设置中的边框绘制
                    } else if(sCode.includes("side")){
                        if (tem[sCode].length > 0){
                            let para = lvglStyleFormatly([sCode, styleName, status, tem[sCode]]);
                            styleCode += "\n\x09" + sCode + "(" + para + ")";
                        }
                        //排除是否是设置字体
                    } else if (sCode.includes("text_font")) {
                        if (isValueNotNull(tem[sCode]["weight"]) && isValueNotNull(tem[sCode]["size"]) && (tem[sCode]["name"] != "SimSun")){
                            let font = "lvgl.font_load(\"" + (tem[sCode]["weight"]).toLowerCase() + "\", " + tem[sCode]["size"] + ")";
                            styleCode += "\n\x09" + sCode + "(" + styleName + ", " + status + ", " + font + ")";
                        }
                    } else {
                        let para = lvglStyleFormatly([sCode, styleName, status, tem[sCode]]);
                        styleCode += "\n\x09" + sCode + "(" + para + ")";
                    }
                }
            }
        }
        allStyleCode = allStyleCode + styleCode;
    }
    // console.log(allStyleCode);
    return allStyleCode;
}

/*
生成控件的事件代码
@tar                控件的事件属性对象
事件有如下：
    lvgl.EVENT_PRESSED,             lvgl.EVENT_PRESS_LOST,              lvgl.EVENT_SHORT_CLICKED,
    lvgl.EVENT_LONG_PRESSED,        lvgl.EVENT_LONG_PRESSED_REPEAT,     lvgl.EVENT_CLICKED,
    lvgl.EVENT_RELEASED,            lvgl.EVENT_DRAG_BEGIN,              lvgl.EVENT_DRAG_END,
    lvgl.EVENT_DRAG_THROW_BEGIN,    lvgl.EVENT_GESTURE,                 lvgl.EVENT_KEY,
    lvgl.EVENT_FOCUSED,             lvgl.EVENT_DEFOCUSED,               lvgl.EVENT_LEAVE,
    lvgl.EVENT_VALUE_CHANGED,       lvgl.EVENT_INSERT,                  lvgl.EVENT_REFRESH,
    lvgl.EVENT_APPLY,               lvgl.EVENT_CANCEL,                  lvgl.EVENT_DELETE,...
格式为：
event: 
{
    CLICKED: 'clickedHandle121', 
    PRESSED: 'pressedHandle1223',
    ...
}
*/
function lvglWidEventInit(tar) {
    let temEventCode = "";
    let temGlobalVarCode = "";
    //添加回调函数
    for (let key in tar) {
        if (key === "event") {
            //定义临时的变量统计是否遍历完所有属性
            let temSum = 1;
            let eventLen = Object.getOwnPropertyNames(tar[key]).length;
            temGlobalVarCode = "\x09" + tar.name.slice(tar.name.indexOf(".") + 1) + " = " + objFun + "(),\n";
            temEventCode += "\x09--This is callBack function of " + tar.name + "\n";
            let temHandleName = tar.name.slice(tar.name.lastIndexOf(".") + 1);
            temEventCode += "\x09local handle" + temHandleName + " = function" + "(obj, e)\n";
            temEventCode += "\x09\x09" + tar.name + ".cb(e)\n";
            temEventCode += "\x09\x09" + tar.name + ".cb = function(e)\n";
            //记录是否存在回调规避name = null 的问题
            let handleNumbers = 0;
            let val;
            for (val in tar[key]) {
                for (let val1 in tar[key][val]) {
                    if (val1 === "type" && tar[key][val][val1] === "invoke") {
                        // let handleName = tar.name.slice(0, tar.name.indexOf(".")) + "." + temHandleName + "_" + tar[key][val]["name"];
                        let handleName = tar[key][val]["name"];
                        if (handleName != null) {
                            //进行全局回调函数变量代码的生成
                            // temGlobalVarCode += "\x09" + temHandleName + "_" + tar[key][val] + " = function()end,\n";
                            //进行回调函数代码的生成
                            if (temSum === 1) {
                                temEventCode += "\x09\x09\x09if (e == lvgl.EVENT_" + val + ")then" +
                                    "\n\x09\x09\x09\x09" + handleName + "()\n";
                            }
                            else {
                                if (temSum === eventLen) {
                                    temEventCode += "\x09\x09\x09elseif (e == lvgl.EVENT_" + val + ")then" +
                                        "\n\x09\x09\x09\x09" + handleName + "()\n";
                                }
                                else {
                                    temEventCode += "\x09\x09\x09elseif (e == lvgl.EVENT_" + val + ")then" +
                                        "\n\x09\x09\x09\x09" + handleName + "()\n";
                                }
                            }
                            temSum += 1;
                            handleNumbers += 1;
                        }
                    }
                    if (val1 === "type" && tar[key][val][val1] === "screen") {
                        // let handleName = tar.name.slice(0, tar.name.indexOf(".")) + "." + temHandleName + "_" + tar[key][val]["name"];
                        let handleName = tar[key][val]["name"];
                        if (handleName != null) {
                            //进行全局回调函数变量代码的生成
                            // temGlobalVarCode += "\x09" + temHandleName + "_" + tar[key][val] + " = function()end,\n";
                            //进行回调函数代码的生成
                            if (temSum === 1) {
                                temEventCode += "\x09\x09\x09if (e == lvgl.EVENT_" + val + ")then\n";
                                temEventCode += "\x09\x09\x09\x09lvgl.obj_del(" + tar["screen"] + ".contFather_" + tar["screen"] + ")\n";
                                temEventCode += "\x09\x09\x09\x09" + tar["screen"] + ".contFather_" + tar["screen"] + " = nil\n";
                                temEventCode += "\x09\x09\x09\x09" + handleName + ".create()\n";
                            }
                            else {
                                if (temSum === eventLen) {
                                    temEventCode += "\x09\x09\x09elseif (e == lvgl.EVENT_" + val + ")then\n";
                                    temEventCode += "\x09\x09\x09\x09lvgl.obj_del(" + tar["screen"] + ".contFather_" + tar["screen"] + ")\n";
                                    temEventCode += "\x09\x09\x09\x09" + tar["screen"] + ".contFather_" + tar["screen"] + " = nil\n";
                                    temEventCode += "\x09\x09\x09\x09" + handleName + ".create()\n";
                                }
                                else {
                                    temEventCode += "\x09\x09\x09elseif (e == lvgl.EVENT_" + val + ")then\n";
                                    temEventCode += "\x09\x09\x09\x09lvgl.obj_del(" + tar["screen"] + ".contFather_" + tar["screen"] + ")\n";
                                    temEventCode += "\x09\x09\x09\x09" + tar["screen"] + ".contFather_" + tar["screen"] + " = nil\n";
                                    temEventCode += "\x09\x09\x09\x09" + handleName + ".create()\n";
                                }
                            }
                            temSum += 1;
                            handleNumbers += 1;
                        }
                    }
                }
            }
            if (handleNumbers > 0) {
                temEventCode += "\x09\x09\x09end\n\x09\x09end\n\x09end\n";
            }
            else {
                temEventCode += "\x09\x09end\n\x09end\n";
            }
        }
    }
    return [temEventCode, temGlobalVarCode];
}

/*
为没有回调的控件进行变量初始化
tar                     控件对象
格式为：
LvglBar1: {
    base: [Object],
    type: 'bar',
    screen: 'sceneA',
    name: 'sceneA.LvglBar',
    style: [Object],
    special: [Object],
    event: [Object]
}
*/
function lvglWidNonEventInit(tar) {
    let temGvCode = "";
    for (let key in tar) {
        if (key === "name") {
            let tem = tar[key].slice(tar[key].indexOf(".") + 1);
            temGvCode += "\x09" + tem + " = " + objFun + "(),\n"
            break;
        }
    }
    return temGvCode;
}

/*
生成元方法代码块,具体如下:
local function objectHide()
    local o = {}
    local tSelf = {}
    setmetatable(o, tSelf)
    tSelf.__index = tSelf
    tSelf.__tostring = function(j)
        return j.self
    end
    tSelf.self = nil
    return o
end
*/
function lvglMateCodeInit() {
    let mateCode = "";
    let tSelf = "tSelf";

    mateCode += "local function " + objFun + "()\n" +
        "\x09local o = {}\n" + "\x09local " + tSelf + " = {}\n" +
        "\x09setmetatable(o, " + tSelf + ")\n" +
        "\x09" + tSelf + ".__index = " + tSelf + "\n" +
        "\x09" + tSelf + ".__tostring = function(j)\n" +
        "\x09\x09return j." + objectSelf + "\n" + "\x09end\n" +
        "\x09" + tSelf + ".__tocall = function(j)\n" +
        "\x09\x09return j.cb" + "\n" + "\x09end\n" +
        "\x09" + tSelf + "." + objectSelf + " = nil\n" +
        "\x09" + tSelf + ".cb" + " = function(e) end\n" +
        "\x09return o\n" +
        "end\n\n"
    return mateCode
}

/*
数组去重，并且标记去重的元素
@tar:               去重数组
@return
    arr:            去重后的数组
    recordArr:      被标记的去重元素
*/
function removeArrayDuplicates(tar){
    let obj = {}, recordArr = [], arr;
    tar.forEach((e) => {
        if(obj[e])
            obj[e]++;
        else
            obj[e] = 1;
    });
    for (key in obj){
        if (obj[key] > 1) {
            recordArr[recordArr.length] = key
        }
    }

    arr = tar.reduce((prev,cur) =>
    prev.includes(cur) ? prev
    : [...prev,cur],[]);
    return [arr, recordArr]
}

/*
判断如何对事件文件进行修改
@newEventArr:          当前的事件json中的函数名称组成的表
@oldEventArr:          事件函数文件中的已存在的函数名称组成的表
@return:        
    para1:      待生成事件组成的表
    para2:      提示是否是改变值还是新增值
*/
function lvglEventFileChangeInit(newEventArr, oldEventArr) {
    //最后返回的事件表
    let retArr;
    retArr = [];
    //提示是否是进行函数名称的替换
    let isChange = "add";
    let temArr;

    let repeatRet = removeArrayDuplicates(newEventArr);
    newEventArr = repeatRet[0];
    repeatHandle = repeatRet[1];

    temArr = newEventArr.concat(oldEventArr).filter(function (v, i, arr) {
        return arr.indexOf(v) === arr.lastIndexOf(v);
    });
    //判断是否是删除事件
    //当新事件数组小于老的事件数组，表示为删除
    if (newEventArr.length < oldEventArr.length) {
        for (let index = 0; index < temArr.length; index++) {
            if (oldEventArr.indexOf(temArr[index]) != -1) {
                retArr[retArr.length] = temArr[index];
            }
        }
        isChange = "delete";
    } else {
        if (newEventArr.length === oldEventArr.length) {
            retArr = temArr
            isChange = "change";
        } else {
            for (let index = 0; index < temArr.length; index++) {
                if (newEventArr.indexOf(temArr[index]) != -1) {
                    retArr[retArr.length] = temArr[index];
                }
            }
        }
    }
    return [retArr, isChange];
}

/*
事件单独代码
@eventName:     事件回调名称
@widName        事件回调的执行控件名称
*/
function lvglPerWidEventFileCodeInit(eventName, tipInfo) {
    let retCode = "";
    retCode += "--This function name and notes cannot be modified\n";
    retCode += "--@@funCfg: <" +
    eventName + ", " + tipInfo + 
    ">\n";
    retCode += "function " + eventName + "()\n" +
        "------------USER CODE DATA--------------\n\n" +
        "------------USER CODE DATA--------------\n" +
        "end\n\n\n";
    return retCode;
}

/*
判断存在函数信息且事件函数的数组
即: 1. 此函数存在
    2. 此函数的注释信息也存在
*/
function findSafeHandleArr(){
    let temEventNameDataArr = originalHandleData.match(/(?<=function ).*?(?=\()/g);
    let temEventTipsDataArr = originalHandleData.match(/(?<=--@@funCfg: <).*?(?=\>)/g);
    let retArr
    retArr = [];

    //错误处理
    if (temEventNameDataArr && temEventTipsDataArr) {
        /* 0: 获取有效的函数信息 */
        temEventTipsDataArr.forEach((element) => {
            console.log("获取有记录事件的函数\n", element.split(",")[0], element.split(",")[1]);
            //排除函数信息被破坏
            if (element.split(",")[1] === " exist" || element.split(",")[1] === " noexist") {
                //获取有效函数信息
                if (typeof (element.split(",")[0]) === "string") {
                    retArr[retArr.length] = element.split(",")[0];
                }
            }
        });
    }

    return retArr;
}

/*
事件代码文件的初始化
@newEventArr:       json 文件中的函数信息
@oldEventArr:      事件文件中的实际信息
*/
function lvglWidEventFileInit(newEventArr, oldEventArr) {
    let retCode = originalHandleData;
    // 原始的全部函数信息
    let oldRecordData = (retCode.toString()).match(/(?<=--@@funCfg: <).*?(?=\>)/g);
    //目标事件对象
    // console.log('[LOG - new]: ', newEventArr);
    // console.log('[LOG - old]: ', oldEventArr);
    let tarEvent = lvglEventFileChangeInit(newEventArr, oldEventArr);

    if (tarEvent.length > 0){
        if (tarEvent[1] === "add"){
            if (tarEvent[0].length === 1){
                //获取记录的事件函数
                let temSafeHandleArr = findSafeHandleArr();
                // console.log("[temSafeHandleArr]\n", temSafeHandleArr);
                
                if (temSafeHandleArr.length > 0){
                    if (temSafeHandleArr.indexOf(tarEvent[0][0]) !== -1){
                        let oriStr = "--@@funCfg: <" + tarEvent[0][0] +  ", noexist>";
                        let tarStr = "--@@funCfg: <" + tarEvent[0][0] +  ", exist>";
                        retCode = retCode.replace(oriStr, tarStr);
                        
                    } else {
                        retCode += lvglPerWidEventFileCodeInit(tarEvent[0][0], "exist");
                    }
                } else {
                    retCode += lvglPerWidEventFileCodeInit(tarEvent[0][0], "exist");
                }
            } else {
                for (let i = 0; i < tarEvent[0].length; i++){
                    // 判断事件文件中是否已存在要添加的函数
                    let oriStr = "--@@funCfg: <" + tarEvent[0][i] +  ", noexist>";
                    let tarStr = "--@@funCfg: <" + tarEvent[0][i] +  ", exist>";
                    if (retCode.match(oriStr)){
                        retCode = retCode.replace(oriStr, tarStr);
                    } else {
                        retCode += lvglPerWidEventFileCodeInit(tarEvent[0][i], "exist");
                    }
                }
            }
        }else if (tarEvent[1] === "delete" && tarEvent[0].length === 1){
            let oriStr = "--@@funCfg: <" + tarEvent[0] +  ", exist>";
            let tarStr = "--@@funCfg: <" + tarEvent[0] +  ", noexist>";
            retCode = retCode.replace(oriStr, tarStr);
        }else if (tarEvent[1] === "change" && tarEvent[0].length === 2){
            let oriStrInfoExist = "--@@funCfg: <" + tarEvent[0][1] +  ", exist>";
            let oriStrInfoNoexist = "--@@funCfg: <" + tarEvent[0][1] +  ", noexist>";
            let tarStrInfoExist = "--@@funCfg: <" + tarEvent[0][0] +  ", exist>";
            let tarStrInfoNoexist = "--@@funCfg: <" + tarEvent[0][0] +  ", noexist>";

            // 判断想要修改的函数名称是否已存在但未被使用
            let findTips = tarEvent[0][0] + ", noexist"
            if (oldRecordData.includes(findTips)){
                retCode = retCode.replace(tarStrInfoNoexist, tarStrInfoExist);
                if (!repeatHandle.includes(tarEvent[0][1])){
                    retCode = retCode.replace(oriStrInfoExist, oriStrInfoNoexist);
                }
            } else {
                let oriStr = "function " + tarEvent[0][1] + "()";
                let tarStr = "function " + tarEvent[0][0] + "()";
                retCode = retCode.replace(oriStrInfoExist, tarStrInfoExist);
                retCode = retCode.replace(oriStr, tarStr);
            }
        }
    }

    return retCode;
}

/*
默认的屏幕父级的样式代码
*/
function lvglDefScrParentContStyleInit(){
    let str = "--This is default style of cont which border is invisible\n"
    str += defContStyleName + " = lvgl.style_t()\n";
    str += "lvgl.style_init(" + defContStyleName + ")\n";
    str += "lvgl.style_set_radius(" + defContStyleName + ", (lvgl.STATE_DEFAULT or LV_STATE_FOCUSED or LV_STATE_PRESSED), 0)\n"
    str += "lvgl.style_set_border_opa(" + defContStyleName + ", (lvgl.STATE_DEFAULT or LV_STATE_FOCUSED or LV_STATE_PRESSED), 0)\n\n";
    return str;
}

/*
默认的键盘和输入框的绑定联动代码初始化
为键盘和输入框添加通用的绑定事件代码
*/
function lvglDefKeyBoardAndTextareaBindInt(){
    let str = "";
    //输入框绑定
    str += "local function lvgl_UiDesigner_DefOutCb(o, e, output)\n";
    str += "\x09if e == lvgl.EVENT_CLICKED then\n";
    str += "\x09\x09lvgl.obj_set_hidden(output, false)\n";
    str += "\x09\x09lvgl.keyboard_set_textarea(output, o)\n";
    str += "\x09elseif e == lvgl.EVENT_DEFOCUSED then\n";
    str += "\x09\x09lvgl.obj_set_hidden(output, true)\n";
    str += "\x09end\nend\n\n";

    //键盘绑定
    str += "local function lvgl_UiDesigner_DefInCb(o, e)\n";
    str += "\x09lvgl.keyboard_def_event_cb(o, e)\n";
    str += "\x09if e == lvgl.EVENT_CANCEL or e == lvgl.EVENT_APPLY then\n";
    str += "\x09\x09lvgl.obj_set_hidden(o, true)\n";
    str += "\x09end\nend\n\n";
    return str;
}

/*
lvgl控件代码生成
@tar:               控件的信息对象(接受来自函数 styleManage() 返回的json数据)
@cfg:               控件信息对象中的配置信息
@callBackFileData:  JSON 文件中的所有事件表
格式为：
[
    {
        schema3: {
            base: { width: 100, height: 100, x: 79, y: 100, align: 'OUT_BOTTOM_MID' },
            type: 'arc',
            screen: 'sceneA',
            name: 'sceneA.blockA9',
            style: {
                'lvgl.ARC_PART_MAIN': {
                    'lvgl.STATE_DEFAULT': {
                        'lvgl.style_set_radius': 20,
                        'lvgl.style_set_bg_color': '0xFFFFFF',
                        'lvgl.style_set_bg_opa': 0.8,
                        'lvgl.style_set_bg_grad_color': '0xFFFFFF',
                        'lvgl.style_set_bg_main_stop': 20,
                        'lvgl.style_set_bg_grad_stop': 250,
                        'lvgl.style_set_bg_grad_dir': 'HOR',
                        'lvgl.style_set_bg_blend_mode': 'NORMAL',
                        'lvgl.style_set_bg_op_y': 30
                    },
                    styName: 'Style_schema3_1',
                    objName: 'sceneA.blockA9'
                },
                ...
            },
            "special": [Object]
            "event": {
                "CLICKED": {
                    "type": 'invoke',
                    "name": 'clickedHandle'
                },
                "PRESSED": {
                    "type": 'window',
                    "name": 'pressedHandle'
                },
            }
        }
    },
    ...
]
*/
function lvglJsonToCode(tar, cfg, callBackFileData) {
    //所有的样式代码块
    // let allStyleCode = "";
    //0--单个屏幕样式代码块
    let singleScrStyleCode = "";
    //控件所有的基本代码块
    let allBaseCode = "";
    //全局变量代码块
    let allGlobalVarCode = "";
    //标志为首次获取屏幕
    let isInitScreen = true;
    let curScreen;
    //事件文件代码
    let allEventCode;
    // 添加文件注释块，提醒文件使用者
    allGlobalVarCode += "----------------------------------------------------------------------------\n" +
        "-- 1. This file automatically generates code for the LuatOS's UI designer\n" +
        "-- 2. In case of accident, modification is strictly prohibited\n" +
        "----------------------------------------------------------------------------\n\n";
    // 添加事件文件载入代码
    allGlobalVarCode += "--Import event file" + "\nrequire \"UiHandle\"\n\n";
    //添加元方法代码块
    allGlobalVarCode += lvglMateCodeInit();

    /* 错误判断，防止数据存在问题 */
    if (tar.length == 0 || tar == []){
        //注销事件文件中的所有事件
        originalHandleData = originalHandleData.replace(/(?<=--@@funCfg: (<\w+)\, )(.*)(?=\>)/g, "noexist");
        return [undefined, originalHandleData];
    }

    //获取资源信息
    resource = cfg;

    //遍历属性数组
    for (let i = 0; i < tar.length; i++) {
        for (let tem in tar[i]) {
            if (isInitScreen) {
                isInitScreen = false;
                curScreen = tar[i][tem].screen;
                allBaseCode += "----------------------------------------------------------------------------\n" +
                    "--The following is the content of screen: " + curScreen + "\n" +
                    "---------------------------------------------------------------------------\n";
                //添加全局变量
                allGlobalVarCode += curScreen + " = \n{\n\x09" + scrLoad + " = nil, \n";
                allGlobalVarCode += "\x09" + scrFree + " = nil,\n";
                allGlobalVarCode += "\x09contFather_" + curScreen + " = nil,\n";
                allBaseCode += curScreen + "." + scrLoad + " = function()\n";
                // 添加屏幕旋转代码
                let temIsHasRotation = cfg["device"];
                if (temIsHasRotation.hasOwnProperty("rotation")) {
                    allBaseCode += "\x09lvgl.disp_set_rotation(nil, lvgl." + cfg["device"]["rotation"] + ")\n";
                }
                //添加屏幕控件的总父级容器
                allBaseCode += "\x09" + curScreen + "." + "contFather_" + curScreen + " = lvgl.cont_create(lvgl.scr_act(), nil)\n";
                allBaseCode += "\x09lvgl.obj_set_size(" + curScreen + "." + "contFather_" + curScreen + ", " + cfg["device"].width + ", " + cfg["device"].height + ")\n";
                allBaseCode += "\x09lvgl.obj_align(" + curScreen + "." + "contFather_" + curScreen + ", nil, lvgl.ALIGN_IN_TOP_LEFT, 0, 0)\n";
                allBaseCode += "\x09lvgl.obj_add_style(" + curScreen + "." + "contFather_" + curScreen + ", lvgl.CONT_PART_MAIN, " + defContStyleName + ")";
                break;
            }
            break;
        }
        for (let a in tar[i]) {
            //获取某个控件的样式代码
            let widAllStyleCode = lvglWidStyleInit(tar[i][a]);
            // allStyleCode += widAllStyleCode;
            //0--获取单个控件样式
            singleScrStyleCode = widAllStyleCode;
            //获取回调事件的代码
            let temAllBaseCode = lvglWidEventInit(tar[i][a]);
            //判断同一个屏幕的控件
            if (curScreen != tar[i][a].screen) {
                //0--重置屏幕样式代码块
                singleScrStyleCode = "";
                allBaseCode += "end\n";
                //添加屏幕销毁函数
                allBaseCode += curScreen + "." + scrFree + " = function()\n";
                allBaseCode += "\x09lvgl.obj_del(" + curScreen + ".contFather_" + curScreen + ")\n";
                allBaseCode += "\x09" + curScreen + ".contFather_" + curScreen + " = nil\nend\n\n";
                //设置当前新的屏幕
                curScreen = tar[i][a].screen;
                allBaseCode += "----------------------------------------------------------------------------\n" +
                    "--The following is the content of screen: " + curScreen + "\n" +
                    "---------------------------------------------------------------------------";
                //添加全局变量
                allGlobalVarCode += "}\n" + curScreen + " = \n{\n\x09" + scrLoad + " = nil, \n";
                allGlobalVarCode += "\x09" + scrFree + " = nil,\n";
                allGlobalVarCode += "\x09contFather_" + curScreen + " = nil,\n";
                allBaseCode += "\n" + curScreen + "." + scrLoad + " = function()\n";
                //添加屏幕旋转代码
                let temIsHasRotation = cfg["device"];
                if (temIsHasRotation.hasOwnProperty("rotation")) {
                    allBaseCode += "\x09lvgl.disp_set_rotation(nil, lvgl." + cfg["device"]["rotation"] + ")\n";
                }
                //添加屏幕控件的总父级容器
                allBaseCode += "\x09" + curScreen + "." + "contFather_" + curScreen + " = lvgl.cont_create(lvgl.scr_act(), nil)\n";
                allBaseCode += "\x09lvgl.obj_set_size(" + curScreen + "." + "contFather_" + curScreen + ", " + cfg["device"].width + ", " + cfg["device"].height + ")\n";
                allBaseCode += "\x09lvgl.obj_align(" + curScreen + "." + "contFather_" + curScreen + ", nil, lvgl.ALIGN_IN_TOP_LEFT, 0, 0)\n";
                allBaseCode += "\x09lvgl.obj_add_style(" + curScreen + "." + "contFather_" + curScreen + ", lvgl.CONT_PART_MAIN, " + defContStyleName + ")";
                //0--为最后一个控件设置样式添加单个屏幕样式
                allBaseCode += widAllStyleCode;
            }
            //0--添加单个屏幕样式
            allBaseCode += singleScrStyleCode;
            //获取某个控件的基础代码
            allBaseCode += lvglwidInit(tar[i][a]);
            //获取某个控件的事件代码
            if (tar[i][a].hasOwnProperty("event")) {
                allBaseCode += "\x09--This is to add callback function for " + tar[i][a].name + "\n";
                allBaseCode += temAllBaseCode[0];
                let temName = tar[i][a].name.slice(tar[i][a].name.lastIndexOf(".") + 1);
                allBaseCode += "\x09lvgl.obj_set_event_cb(" + tar[i][a].name + widObjName + ", " + "handle" + temName + ")\n";
                //添加有事件控件全局变量
                allGlobalVarCode += temAllBaseCode[1]
            } else {
                //添加无事件控件全局变量
                allGlobalVarCode += lvglWidNonEventInit(tar[i][a]);
            }
        }
    }
    //对最后的函数进行结束补充
    allGlobalVarCode += "}\n";
    allBaseCode += "end\n";
    //为最后的屏幕添加屏幕销毁函数
    allBaseCode += curScreen + "." + scrFree + " = function()\n";
    allBaseCode += "\x09lvgl.obj_del(" + curScreen + ".contFather_" + curScreen + ")\n";
    allBaseCode += "\x09" + curScreen + ".contFather_" + curScreen + " = nil\nend\n\n";
    //为空白屏幕添加全局变量(即屏幕中无任何控件), 防止意外情况发生.
    for (let j = 0; j < cfg["screens"].length; j++) {
        if (cfg["screens"][j]["layout"]["blocks"].length === 0) {
            let curPureScreen = cfg["screens"][j]["name"];
            allGlobalVarCode += curPureScreen + " = \n{\n\x09" + scrLoad + " = nil, \n";
            allGlobalVarCode += "\x09" + scrFree + " = nil,\n";
            allGlobalVarCode += "\x09contFather_" + curPureScreen + " = nil,\n}\n";

            allBaseCode += "\n\n----------------------------------------------------------------------------\n" +
                "--The following is the content of screen: " + curPureScreen + "\n" +
                "---------------------------------------------------------------------------";
            allBaseCode += "\n" + curPureScreen + "." + scrLoad + " = function()\n";
            allBaseCode += "\x09" + curPureScreen + "." + "contFather_" + curPureScreen + " = lvgl.cont_create(lvgl.scr_act(), nil)\n";
            allBaseCode += "\x09lvgl.obj_set_size(" + curPureScreen + "." + "contFather_" + curPureScreen + ", " + cfg["device"].width + ", " + cfg["device"].height + ")\n";
            allBaseCode += "\x09lvgl.obj_align(" + curPureScreen + "." + "contFather_" + curPureScreen + ", nil, lvgl.ALIGN_IN_TOP_LEFT, 0, 0)\n";
            allBaseCode += "\x09lvgl.obj_add_style(" + curScreen + "." + "contFather_" + curScreen + ", lvgl.CONT_PART_MAIN, " + defContStyleName + ")\nend\n";
            //添加屏幕销毁函数
            allBaseCode += curPureScreen + "." + scrFree + " = function()\n";
            allBaseCode += "\x09lvgl.obj_del(" + curPureScreen + ".contFather_" + curPureScreen + ")\n";
            allBaseCode += "\x09" + curPureScreen + ".contFather_" + curPureScreen + " = nil\nend\n\n";
        }
    }

    //为默认的父级屏幕设置一个默认样式
    allGlobalVarCode += lvglDefScrParentContStyleInit();

    //添加键盘和输入框的通用绑定事件代码
    allGlobalVarCode += lvglDefKeyBoardAndTextareaBindInt();

    //2--事件文件初始化
    allEventCode = lvglWidEventFileInit(callBackFileData, originalHandleTable);

    //添加一个固定的屏幕初始化调用函数
    allBaseCode += "\n----------------------------------------------------------------------------\n" +
        "-----------------------This is the Initial of lvglGUI-----------------------\n" +
        "----------------------------------------------------------------------------\n";
    allBaseCode += "function lvglUiInitial()\n\x09" + cfg["screens"][0]["name"] + ".create()\nend\n";

    return [allGlobalVarCode + allBaseCode, allEventCode];
}

/*
获取事件回调文件中的有效函数信息
@eventNameArr:          事件文件中的所有存在的函数名称组成的数组
@eventTipsArr:          事件文件中所有被记录信息的函数所组成的数组
*/
function findOriginalEventArr(eventNameArr, eventTipsArr) {
    //有效函数数组
    let effectArr;
    effectArr = [];

    //错误处理
    if (eventNameArr && eventTipsArr) {
        /* 0: 获取有效的函数信息 */
        eventTipsArr.forEach((element) => {
            // console.log(element.split(",")[0], element.split(",")[1]);
            //排除函数信息被破坏
            if (element.split(",")[1] === " exist" || element.split(",")[1] === " noexist") {
                //获取有效函数信息
                if (element.split(",")[1] === " exist" && (typeof (element.split(",")[0]) === "string")) {
                    effectArr[effectArr.length] = element.split(",")[0];
                }
            }
        });
        /* 1: 获取实际的原始函数信息 */
        return eventNameArr.filter(function (val) { return effectArr.indexOf(val) > -1 });
    }

    return [];
}

/*
转码器初始化
@isAir:             代码生成的对应版本
@uiJson:            要生成代码的json对象
@handleBuffer:      uiHandle文件流数据
*/
function transcoderInitialization(codeVersion, uiJson, handleBuffer) {
    // outputObj对象
    let outputObj = { 
        uiDesignLua:'',
        uiHandleLua:''
    };

    /* 判断代码的生成版本 */
    codeVersion == "air" ? isSoc = false : isSoc = true;

    /* 0: 给初始化事件表 */
    originalHandleTable = [];

    //读取回调函数文件中的数据
    //赋值原始数据
    originalHandleData = (handleBuffer.toString());
    let temEventNameArr = (handleBuffer.toString()).match(/(?<=function ).*?(?=\()/g);
    let temEventTipsArr = (handleBuffer.toString()).match(/(?<=--@@funCfg: <).*?(?=\>)/g);
    // console.log("temEventNameArr\n", temEventNameArr);
    // console.log("temEventTipsArr\n", temEventTipsArr);
    originalHandleTable =  findOriginalEventArr(temEventNameArr, temEventTipsArr);

    let theTarget = styleManage(uiJson);
    //获取生成的 lua 数据
    let luaCodeData = lvglJsonToCode(theTarget[0], theTarget[1], theTarget[2]);

    //生成ui.lua文件
    outputObj.uiDesignLua = luaCodeData[0];
    //生成ui.lua文件的事件文件
    outputObj.uiHandleLua = luaCodeData[1];
    
    return outputObj;
}